Gut microbiota and metabolites are considered key factors in the pathogenesis of perioperative neurocognitive disorders (PND), and the brain-gut axis may be a promising target for PND treatment. Electroacupuncture has been shown to improve a wide range of neurological disorders and to restore function to the gastrointestinal tract. Thus, we hypothesized whether electroacupuncture could remodel gut microbiota and neuroinflammation induced by anesthesia/surgery. First, we observed electroacupuncture at acupoints GV20, LI4 and PC6 significantly improved memory in behavioral tests. Next, we found electroacupuncture decreased the levels of inflammatory factors (NSE, S-100β, IL-6, etc.) in the hippocampus, indicating that nerve inflammation was blocked by electroacupuncture. Furthermore, via 16S rRNA sequence analysis and LC-MS analysis, the gut microbiota and its metabolites were appropriately restored after electroacupuncture treatment. Additionally, we further confirmed the restorative effect of electroacupuncture on PND by fecal transplantation. In conclusion, the role of electroacupuncture in improving cognitive function and protecting neurons may be related to the modulation of gut microbiota and their metabolite dysregulation, thereby inhibiting neuroinflammation in PND mice.