Understanding the mechanisms by which long-term memories are formed and stored in the brain represents a central aim of neuroscience. Prevailing theory suggests that long-term memory encoding involves early plasticity within hippocampal circuits, whereas reorganization of the neocortex is thought to occur weeks to months later to subserve remote memory storage. Here we report that long-term memory encoding can elicit early transcriptional, structural, and functional remodeling of the neocortex. Parallel studies using genome-wide RNA sequencing, ultrastructural imaging, and whole-cell recording in wild-type mice suggest that contextual fear conditioning initiates a transcriptional program in the medial prefrontal cortex (mPFC) that is accompanied by rapid expansion of the synaptic active zone and postsynaptic density, enhanced dendritic spine plasticity, and increased synaptic efficacy. To address the real-time contribution of the mPFC to long-term memory encoding, we performed temporally precise optogenetic inhibition of excitatory mPFC neurons during contextual fear conditioning. Using this approach, we found that real-time inhibition of the mPFC inhibited activation of the entorhinal–hippocampal circuit and impaired the formation of long-term associative memory. These findings suggest that encoding of long-term episodic memory is associated with early remodeling of neocortical circuits, identify the prefrontal cortex as a critical regulator of encoding-induced hippocampal activation and long-term memory formation, and have important implications for understanding memory processing in healthy and diseased brain states.