Early social environment, either positive or negative, shapes the adult brain. Communal nesting (CN), a naturalistic setting in which 2-3 females keep their pups in a single nest sharing care-giving behavior, provides high level of peer interaction for pups. Early social isolation (ESI) from dam and siblings represents, instead, an adverse condition providing no peer interaction. We investigated whether CN (enrichment setting) might influence the response to ESI (impoverishment setting) in terms of social behavior and glutamate system in the medial prefrontal cortex (mPFC) of adult and adolescent male and female rats. Pinning (a rewarding component of social play behavior) was significantly more pronounced in males than in females exposed to the combination of CN and ESI. CN sensitized the glutamate synapse in the mPFC of ESI-exposed male, but not female, rats. Accordingly, we observed (i) a potentiation of the glutamatergic neurotransmission in the mPFC of both adolescent and adult males, as shown by the recruitment of NMDA receptor subunits together with increased expression/activation of PSD95, SynCAM 1, Synapsin I and αCaMKII; (ii) a de-recruiting of NMDA receptors from active synaptic zones of same-age females, together with reduced expression/activation of the above-mentioned proteins, which might reduce the glutamate transmission. Whether similar sex-dependent glutamate homeostasis modulation occurs in other brain areas remains to be elucidated. CN and ESI interact to shape social behavior and mPFC glutamate synapse homeostasis in an age- and sex-dependent fashion, suggesting that early-life social environment may play a crucial role in regulating the risk to develop psychopathology.