The efficient coding hypothesis postulates that neurons shape their response properties to match their dynamic range to the statistics of incoming signals. However, whether and how the dynamics of efficient neuronal adaptation inform behavior has not been directly shown. Here, we trained mice to detect a target presented in background noise shortly after a change in the background contrast. The observed changes in cortical gain and detection behavior followed the predictions of a normative model of efficient cortical sound processing; specifically, target detection and sensitivity to target volume improved in low contrast backgrounds relative to high contrast backgrounds. Additionally, the time course of target detectability adapted asymmetrically depending on contrast, decreasing rapidly after a transition to high contrast, and increasing more slowly after a transition to low contrast. Auditory cortex was required for detection of targets in background noise and cortical neuronal responses exhibited the patterns of target detectability observed during behavior and in the normative model. Furthermore, variability in cortical gain predicted behavioral performance beyond the effect of stimulus-driven gain control. Combined, our results demonstrate that efficient neural codes in auditory cortex directly influence perceptual behavior.