This study examined whether depression is associated with an increased risk of a higher Dietary Inflammatory Index (DII) or energy-adjusted DII (E-DII) and whether insulin resistance (IR) plays a mediating role in this relationship. Data from the National Health and Nutrition Examination Survey (NHANES) 2005–2018 were analyzed. Univariate analyses of continuous and categorical variables were conducted using t-tests, ANOVA, and χ² tests. Logistic regression assessed the association between DII/E-DII and depression across three models. Mediation analysis was performed to evaluate whether homeostatic model assessment-insulin resistance (HOMA-IR) mediated this association. A total of 70,190 participants were included. The depressed group had a higher DII score, which was significantly associated with all participant characteristics except age (p < 0.05). In the fully adjusted model (Model 3), individuals in the highest DII quartile had significantly higher odds of depression (OR: 1.82, 95% CI: 1.28–2.58) compared to those in the lowest quartile, with a significant dose–response trend (p-trend < 0.05). However, no interaction between DII and HOMA-IR was observed in relation to depression risk, and HOMA-IR did not mediate the association between DII and depression. Similar findings were observed for E-DII. The findings suggest that a pro-inflammatory diet is associated with an increased risk of depression in U.S. adults. However, there was no evidence of a synergistic effect between DII/E-DII and HOMA-IR on depression risk, nor of a mediating role of HOMA-IR in this relationship.