Almost half of pregnant women globally are currently estimated to be overweight or obese. Rates of childhood obesity are also on the rise, in part because of increased consumption of dietary saturated fats. However, the long‐term effect of peri‐ and postnatal high fat (HF) feeding on cognitive function and neuronal expression has not yet been investigated. Male and female C57BL/6J mice born to dams fed a control (C) or high fat (HF) diet were themselves fed either the C or HF diet, generating four experimental groups: C/C, C/HF, HF/C, and HF/HF, representing the peri‐ and postnatal diets, respectively. Offspring underwent evaluation of executive function using the two‐choice paired visual discrimination reversal (PVDR) task at 6 and 12 months of age. Brain tissues were then processed for markers of serotonin, GABA, glutamate, and acetylcholine using RT‐qPCR, Western blotting, and immunohistochemistry. At 6 months of age, C/HF and HF/HF mice performed significantly worse on the PVDR task compared to C/C and HF/C offspring. Perinatal diet did not affect performance at this age. However, 12‐month‐old HF/C males reached criteria more quickly than C/C male mice, suggesting improved cognitive performance. Levels of NeuN were increased in the prefrontal cortex of HF/C animals, alongside a selective increase in markers of acetylcholine. These results suggest that postnatal HF feeding negatively impacts executive function in both adult and aged mice, but consumption of the same diet during the perinatal period only may be beneficial in older age, possibly due to increased cholinergic innervation of the prefrontal cortex.