The detailed mechanism of inflammation in postoperative cognitive dysfunction (POCD) is unclear. This study aimed to determine whether electroacupuncture (EA) ameliorates POCD by modulating gut microbial dysbiosis. Compared to the control group, mice in the EA group were treated at the acupoints Zusanli (ST36), Quchi (L111), Baihui (GV20), and Dazhui (GV14) 1 week before appendectomy. Novel object recognition and the Morris water maze tests were used to assess learning and spatial reference memory deficits, whereas hippocampus samples and stool samples were collected for central inflammatory tests and 16S‐rRNA sequencing of intestinal flora, respectively. In amyloid precursor protein/presenilin 1 (APP/PS1) mice, EA enhanced spatial memory and learning deficits. The fecal microbial community was altered in APP/PS1 mice in the absence of EA following surgery. Among them, Coprococcus and Bacteroidetes were more abundant in the EA groups than in the control groups; however, Actinobacteriota, Helicobacteraceae, and Escherichia/shigella constitute the minor bacterial colonization in the EA groups. Furthermore, we found a significant negative correlation between Firmicutes and escape latency (Pearson correlation coefficient − 0.551, p < 0.01) and positive correlation between Proteobacteria and escape latency (Pearson correlation coefficient 0.462, p < 0.05). Electron microscopy revealed signs of blood–brain barrier (BBB) impairments and immunofluorescence images showed glial cells activated in the hippocampus of APP/PS mice without EA, and serum diamine oxidase levels were increased in these mice; whereas EA treatment significantly relieved the above pathological changes. Our findings implied that EA decreases hippocampal inflammation of APP/PS1 by upregulating benificial gut microbiota, reducing BBB and intestinal barrier dysfunction, thus alleviates postoperative cognitive dysfunction. This may provide a novel target in POCD management.