Depression is a mental disorder affecting more than 300 million people in the world. Abnormalities in white matter are associated with the development of depression. Here, the authors show that mice with oligodendrocyte‐specific deletion of Nerve injury‐induced protein 2 (Ninj2) exhibit depressive‐like behaviors. Loss of Ninj2 in oligodendrocytes inhibits oligodendrocyte development and myelination, and impairs neuronal structure and activities. Ninj2 competitively inhibits TNFα/TNFR1 signaling pathway by directly binding to TNFR1 in oligodendrocytes. Loss of Ninj2 activates TNFα‐induced necroptosis, and increases C‐C Motif Chemokine Ligand 2 (Ccl2) production, which might mediate the signal transduction from oligodendrocyte to neurons. Inhibition of necroptosis by Nec‐1s administration synchronously restores oligodendrocyte development, improves neuronal excitability, and alleviates depressive‐like behaviors. This study thus illustrates the role of Ninj2 in the development of depression and myelination, reveals the relationship between oligodendrocytes and neurons, and provides a potential therapeutic target for depression.