Motor skill learning induces long-lasting reorganization of dendritic spines, principal sites of excitatory synapses, in the motor cortex. However, mechanisms that regulate these excitatory synaptic changes remain poorly understood. Here, using in vivo two-photon imaging in awake mice, we found that learning-induced spine reorganization of layer (L) 2/3 excitatory neurons occurs in the distal branches of their apical dendrites in L1 but not in the perisomatic dendrites. This compartment-specific spine reorganization coincided with subtype-specific plasticity of local inhibitory circuits. Somatostatin-expressing inhibitory neurons (SOM-INs), which mainly inhibit distal dendrites of excitatory neurons, showed a decrease in axonal boutons immediately after the training began, whereas parvalbumin-expressing inhibitory neurons (PV-INs), which mainly inhibit perisomatic regions of excitatory neurons, exhibited a gradual increase in axonal boutons during training. Optogenetic enhancement and suppression of SOM-IN activity during training destabilized and hyperstabilized spines, respectively, and both manipulations impaired the learning of stereotyped movements. Our results identify SOM inhibition of distal dendrites as a key regulator of learning-related changes in excitatory synapses and the acquisition of motor skills.