Based on the results of single factor experiments, response surface methodology was used to optimize the extraction conditions of flavonoids from Penthorum chinense Pursh (PCF). The optimal extraction conditions were the ratio of liquid to material 22 mL/g, ethanol concentration 68%, extraction temperature 82 °C, and extraction time 2.2 h, respectively. Under these optimized conditions, the PCF yield was 10.72%, which closely agreed with the predicted value (10.75%). In addition, PCF significantly scavenged DPPH radical, hydroxyl radical and superoxide radical in vitro. In the in vivo assays, PCF enhanced the resistance of Caenorhabditis elegans against heat stress, which might be attributed to PCF increased the activities of catalase (CAT) and superoxide dismutase (SOD), and decreased the level of malondialdehyde (MDA). In summary, these results suggested that the optimized extraction was a very effective method to extract PCF and the PCF could be explored as a potential antioxidant for medicine and function food.