The mammalian dorsomedial prefrontal cortex (dmPFC) receives diverse inputs and plays important roles in adaptive behavior and cognitive flexibility. Stress, a major risk factor for many psychiatric disorders, compromises the structure and function of multiple brain regions and circuits. Here we show that 7-day restraint stress impairs reversal learning in the 4-choice odor discrimination test, a decision-making task requiring an intact dmPFC. In vivo two-photon imaging further reveals that stress increases dmPFC dendritic spine elimination, particularly those of the mushroom morphology, without affecting spine formation. In addition, stress alters dmPFC microglial branching complexity and elevates their terminal process dynamics. In stressed mice, dmPFC microglia contact dendrites more frequently, and dendritic spines with microglial contact are prone to elimination. In summary, our work suggests that stress-induced changes in glial-synapse interaction contributes to synaptic loss in dmPFC, resulting in neuronal circuit deficits and impaired cognitive flexibility.