Pregnancy and the postpartum period are times of profound behavioral change including alterations in cognitive function. This has been most often studied using hippocampal-dependent tasks assessing spatial learning and memory. However, less is known about the cognitive effects of motherhood for tasks that rely on areas other than the hippocampus. We have previously shown that postpartum females perform better on the extradimensional phase of an attentional set shifting task, a measure of cognitive flexibility which is dependent on the medial prefrontal cortex (mPFC). The present experiments aimed to extend this work by examining the importance of postpartum stage as well as offspring and parity in driving improved mPFC cognitive function during motherhood. We also examined whether the neuropeptide oxytocin, which plays a role in regulating numerous maternal functions, mediates enhanced cognitive flexibility during motherhood. Our results demonstrate that compared to virgin females, cognitive flexibility is enhanced in mothers regardless of postpartum stage and is not affected by parity since both first (primiparous) and second (biparous) time mothers showed the enhancement. Moreover, we found that improved cognitive flexibility in mothers requires the presence of offspring, as removal of the pups abolished the cognitive enhancement in postpartum females. Lastly, using an oxytocin receptor antagonist, we demonstrate that oxytocin signaling in the mPFC is necessary for the beneficial effects of motherhood on cognitive flexibility. Together, these data provide insights into the temporal, experiential and hormonal factors which regulate mPFC-dependent cognitive function during the postpartum period.