Stress, a prevalent experience in modern society, is a major risk factor for many psychiatric disorders. Although sensorimotor abnormalities are often present in these disorders, little is known about how stress affects the sensory cortex. Combining behavioral analyses with in vivo synaptic imaging, we show that stressful experiences lead to progressive, clustered loss of dendritic spines along the apical dendrites of layer (L) 5 pyramidal neurons (PNs) in the mouse barrel cortex, and such spine loss closely associates with deteriorated performance in a whisker-dependent texture discrimination task. Furthermore, the activity of parvalbumin-expressing inhibitory interneurons (PV+ INs) decreases in the stressed mouse due to reduced excitability of these neurons. Importantly, both behavioral defects and structural changes of L5 PNs are prevented by selective pharmacogenetic activation of PV+INs in the barrel cortex during stress. Finally, stressed mice raised under environmental enrichment (EE) maintain normal activation of PV+ INs, normal texture discrimination, and L5 PN spine dynamics similar to unstressed EE mice. Our findings suggest that the PV+ inhibitory circuit is crucial for normal synaptic dynamics in the mouse barrel cortex and sensory function. Pharmacological, pharmacogenetic and environmental approaches to prevent stress-induced maladaptive behaviors and synaptic malfunctions converge on the regulation of PV+ IN activity, pointing to a potential therapeutic target for stress-related disorders.