The axon initial segment (AIS) is a critical microdomain for action potential initiation and implicated in the regulation of neuronal excitability during activity-dependent plasticity. While structural AIS plasticity has been suggested to fine-tune neuronal activity when network states change, whether it acts in vivo as a homeostatic regulatory mechanism in behaviorally relevant contexts remains poorly understood. Using the mouse whisker-to-barrel pathway as a model system in combination with immunofluorescence, confocal analysis and electrophysiological recordings, we observed bidirectional AIS plasticity in cortical pyramidal neurons. Furthermore, we find that structural and functional AIS remodeling occurs in distinct temporal domains: Long-term sensory deprivation elicits an AIS length increase, accompanied with an increase in neuronal excitability, while sensory enrichment results in a rapid AIS shortening, accompanied by a decrease in action potential generation. Our findings highlight a central role of the AIS in the homeostatic regulation of neuronal input-output relations.