To investigate the effects of B. subtilis on the specific immune response of lactating sows to E. coli and the diarrhea rate in suckling piglets, thirty large white sows with similar farrowing dates were randomly divided into two groups: a feedback feeding (i.e., feeding a homogenate of intestinal contents and tissues from E. coli-infected piglets to sows; FB) group and a feedback feeding with B. subtilis (FB + BS) group. Serum, colostrum, and intestinal tissues from sows and piglets were collected to assess the immune response and intestinal barrier function at weaning. T and B cells from Peyer’s patches (PPs) and mesenteric lymph nodes (MLNs) in lactating mice (with treatments consistent with the sows’) were isolated to explore the underlying mechanism. The results showed that, compared with the FB group, the reproductive performance of sows and the growth performance of their offspring were effectively improved in the FB + BS group. Moreover, the levels of IgG/IgA and those of IgG/IgA against E. coli in the serum and colostrum of sows in the FB+BS group were increased (p < 0.05). Meanwhile, the ratio of CD4+/CD8+, CD4+CXCR5+PD1+, and B220+IgA+ cells in MLNs and PPs, and the IgA levels in the mammary glands of mice, were also increased in the FB + BS group (p < 0.05). Notably, in suckling piglets in the FB + BS group, the diarrhea rate was decreased (p < 0.05), and the intestinal barrier function and intestinal flora composition at weaning were significantly improved. Overall, these results indicated that B. subtilis feed supplementation combined with feedback feeding in pregnant and lactating sows can reduce diarrhea in suckling piglets by enhancing the maternal immune response against E. coli and intestinal barrier function in their offspring, improving survival rates and pre-weaning growth.