Neurodevelopmental disorders such as autism spectrum disorder (ASD) have a heterogeneous etiology but are largely associated with genetic factors. Robust evidence from recent human genetic studies has linked mutations in the Shank2 gene to idiopathic ASD. Modeling these Shank2 mutations in animal models recapitulates behavioral changes, e.g. impaired social interaction and repetitive behavior of ASD patients. Shank2-deficient mice exhibit NMDA receptor (NMDAR) hypofunction and associated behavioral deficits. Of note, NMDARs are strongly implicated in cognitive flexibility. Their hypofunction, e.g. observed in schizophrenia, or their pharmacological inhibition leads to impaired cognitive flexibility. However, the association between Shank2 mutations and cognitive flexibility is poorly understood. Using Shank2-deficient mice, we explored the role of Shank2 in cognitive flexibility measured by the attentional set shifting task (ASST) and whether ASST performance in Shank2-deficient mice can be modulated by treatment with the partial NMDAR agonist D-cycloserine (DCS). Furthermore, we investigated the effects of Shank2 deficiency, ASST training, and DCS treatment on the expression level of NMDAR signaling hub components in the orbitofrontal cortex (OFC), including NMDAR subunits (GluN2A, GluN2B, GluN2C), phosphoglycerate dehydrogenase and serine racemase. Surprisingly, Shank2 deficiency did not affect ASST performance or alter the expression of the investigated NMDAR signaling hub components. Importantly, however, DCS significantly improved ASST performance, demonstrating that positive NMDAR modulation facilitates cognitive flexibility. Furthermore, DCS increased the expression of GluN2A in the OFC, but not that of other NMDAR signaling hub components. Our findings highlight the potential of DCS as a pharmacological intervention to improve cognitive flexibility impairments downstream of NMDAR modulation and substantiate the key role of NMDAR in cognitive flexibility.