Cerebral ischemia–reperfusion injury is frequently associated with neuroinflammation. The modulation of microglial polarization presents a promising approach for addressing cerebral ischemia–reperfusion injury. While electroacupuncture preconditioning has demonstrated efficacy in the management of ischemic stroke, the underlying therapeutic mechanisms remain inadequately understood. The investigation focused on elucidating the relationship between alterations in the TLR4/NF-κB/TXNIP/NLRP3 signaling pathway and microglial polarization subsequent to EA pretreatment. Established a middle cerebral artery occlusion (MCAO) rat model following electroacupuncture (EA) treatment at the Baihui (GV 20) acupoint. Male Sprague-Dawley rats were randomly assigned to the sham, Ischemia/Reperfusion (I/R), I/R + EA groups (n = 6). The results of Nissl Staining and TUNEL Stainingl showed that the number of curative neurons increased significantly after pretreatment, indicating an improvement in neuron formation and an increase in the number of austenite. The level of apoptosis in brain tissue in the I/R group was significantly higher than that in the sham operation group. Electroacupuncture pretreatment can effectively inhibit apoptosis occurrence. In addition, electric acupuncture pretreatment protects rat blood–brain barrier integrity and mitochondrial function. After treatment, the number of M1-type microglia decreased, while the number of M2-type microglia increased. These results suggest that EA preconditioning may alleviate neurological deficits and neuronal apoptosis caused by cerebral I/R injury, while maintaining the integrity of the blood–brain barrier and promoting microglial polarization through the TLR4/NF-κB/TXNIP/NLRP3 signaling pathway. Our findings establish a new molecular mechanism and theoretical foundation for electroacupuncture therapy of ischemic stroke.