The gut microbiota plays an important role in parasite-host interactions and the induction of immune defense responses. Trichinella spiralis is an important zoonotic parasite that can directly or indirectly interact with the host in the gut. Changes in the gut microbiota following infection with T. spiralis and the role of the gut microbiota in host immune defense against T. spiralis infection were investigated in our study. 16S rRNA sequencing analysis revealed that infection with T. spiralis can reduce the diversity of the gut microbiota and alter the structure of the gut microbiota during early infection, which was restored when the worm left the gut. Antibiotic treatment (ABX) and fecal bacterial transplantation (FMT) were used to investigate the role of the gut microbiota in the host expulsion response during infection with T. spiralis. We found that ABX mice had a higher burden of parasites, and the burden of parasites decreased after fecal bacterial transplantation. The results of flow cytometry and qPCR revealed that the disturbance of the gut microbiota affects the proportion of CD4+ T cells and the production of IL-4, which weakens Th2 responses and makes expulsion difficult. In addition, as the inflammatory response decreased with the changes of the microbiota, the Th1 response also decreased. The metabolomic results were in good agreement with these findings, as the levels of inflammatory metabolites such as ceramides were reduced in the ABX group. In general, T. spiralis infection can cause changes in the gut microbiota, and the presence or absence of microbes may also weaken intestinal inflammation and the expulsion of T. spiralis by affecting the immune response of the host.