While the precise processes underlying a sex bias in the development of central nervous system (CNS) disorders are unknown, there is growing evidence that an early life immune activation can contribute to the disease pathogenesis. When we mimicked an early systemic viral infection or applied murine cytomegalovirus (MCMV) systemically in neonatal female and male mice, only male adolescent mice presented behavioral deficits, including reduced social behavior and cognition. This was paralleled by an increased amount of infiltrating T cells in the brain parenchyma, enhanced interferon-γ (IFNγ) signaling, and epigenetic reprogramming of microglial cells. These microglial cells showed increased phagocytic activity, which resulted in abnormal loss of excitatory synapses within the hippocampal brain region. None of these alterations were seen in female adolescent mice. Our findings underscore the early postnatal period’s susceptibility to cause sex-dependent long-term CNS deficiencies following infections.