Mastitis can seriously damage the physical and mental health of lactating women. The use of antibiotics and anti-inflammatory drugs may damage the flora balance in lactating women. To alleviate mastitis in lactating women and reduce drug-induced damage to the flora, we found that dehydroandrographolide (Deh) has good anti-inflammatory and bacterial balance functions. In vivo, we found that Deh significantly inhibited the expression of MPO, IL6, IL-1β, TNF-α, COX2 and iNOS and reduced pathological damage to the mammary gland. The feces in the control and Deh groups were collected and sequenced for 16S flora. The results showed that Deh did not change the primary intestinal microflora composition of the two groups. In vitro, our study showed that Deh significantly inhibited the expression of IL6, IL-1β and TNF-α in the EpH4-Ev cell line. When an AMPK inhibitor was added, the anti-inflammatory effect of Deh was blocked. To further study the anti-inflammatory mechanism of Deh, we found that Deh significantly promoted autophagy through the phosphorylation of AMPK, Beclin and ULK1. In conclusion, our study found that Deh promoted autophagy and played an anti-inflammatory role by activating the AMPK/Beclin/ULK1 signaling pathway and did not affect intestinal flora.