This study aimed to explore the association of maternal diet, infant MTHFR gene polymorphisms, and their interactions with the risk of ventricular septal defects (VSDs). This case–control study recruited 448 mothers of VSD children and 620 mothers of healthy counterparts. Multivariable-adjusted logistic regression models were constructed to examine the association between maternal dietary habits during the first trimester of gestation, MTHFR gene polymorphisms, and VSD. Gene–environment interaction effects were analyzed through logistic regression models, with false discovery rate p-value (FDR_p) < 0.05. Maternal excessive intake of fermented bean curd (OR = 2.00, 95%CI: 1.59–2.52), corned foods (OR = 2.23, 1.76–2.84), fumatory foods (OR = 1.75, 1.37–2.23), grilled foods (OR = 1.34, 1.04–1.72), and fried foods (OR = 1.80, 1.42–2.27) was associated with an increased risk of VSD. Regular intake of fish and shrimp (OR = 0.42, 0.33–0.53), fresh eggs (OR = 0.58, 0.44–0.75), soy products (OR = 0.69, 0.56–0.85), and dairy products (OR = 0.71, 0.59–0.85) was found to reduce the occurrence of VSD. Moreover, MTHFR gene polymorphisms at rs2066470 (homozygous: OR = 4.28, 1.68–10.90), rs1801133 (homozygous: OR = 2.28, 1.39–3.74), and rs1801131 (heterozygous: OR = 1.75, 1.24–2.47; homozygous: OR = 3.45, 1.50–7.95) elevated offspring susceptibility to VSDs. Furthermore, significant interactions of MTHFR polymorphisms with maternal dietary habits were observed, encompassing corned foods, fermented bean curd, fried foods, and grilled foods. Maternal dietary habits; MTHFR polymorphisms at rs2066470, rs1801131, and rs1801133; and their interactions were significantly associated with the occurrence of VSDs in offspring.