This study aimed to investigate the antioxidant activity and antibacterial effect of total flavonoids from Persicaria hydropiper (L.) Spach (TFs-Ph) and to provide a theoretical basis for the development of drugs for the treatment of pathogenic Escherichia coli and Salmonella spp. of broiler origin. Firstly, the response surface optimization heating reflux method was used to extract TFs-Ph, and the effects of ethanol concentration, solid–liquid ratio, heating reflux time, heating reflux temperature, and number of extraction times on the extraction yield of TFs-Ph were analyzed to determine the optimal extraction conditions. The antioxidant activity of TFs-Ph was determined by measuring the scavenging ability against hydroxyl radicals (•OH), 1,1-diphenyl-2-picrylhydrazyl (DPPH), superoxide anion (•O2−), and 2,2′-azino-bis (3-ethylbenzothiazoline-6-sulfonic acid) (ABTS). The antibacterial effect of TFs-Ph was determined by the disk diffusion method. The results showed that the optimal extraction parameters of TFs-Ph were as follows: ethanol concentration of 51%, solid-liquid ratio of 1:24 g/mL, heating reflux time of 74 min, heating reflux temperature of 70 °C, and three extraction times; in this case, the extraction yield of TFs-Ph was 6.37%. TFs-Ph had a strong scavenging ability against the free radicals of •OH, DPPH, •O2−, and ABTS, and the antioxidant activity was better than that of vitamin C (Vc). In addition, it showed a better antibacterial effect against pathogenic Escherichia coli and Salmonella of broiler origin compared with ampicillin (AMP). Therefore, TFs-Ph have a certain potential to replace antibiotics.