The time and energetic costs of behavioral responses to incidental and experimental sonar exposures, as well as control stimuli, were quantified using hidden state analysis of time series of acoustic and movement data recorded by tags (DTAG) attached to 12 sperm whales (Physeter macrocephalus) using suction cups. Behavioral state transition modeling showed that tagged whales switched to a non-foraging, non-resting state during both experimental transmissions of low-frequency active sonar from an approaching vessel (LFAS; 1-2 kHz, source level 214 dB re 1 µPa m, four tag records) and playbacks of potential predator (killer whale, Orcinus orca) sounds broadcast at naturally occurring sound levels as a positive control from a drifting boat (five tag records). Time spent in foraging states and the probability of prey capture attempts were reduced during these two types of exposures with little change in overall locomotion activity, suggesting an effect on energy intake with no immediate compensation. Whales switched to the active non-foraging state over received sound pressure levels of 131-165 dB re 1 µPa during LFAS exposure. In contrast, no changes in foraging behavior were detected in response to experimental negative controls (no-sonar ship approach or noise control playback) or to experimental medium-frequency active sonar exposures (MFAS; 6-7 kHz, source level 199 re 1 µPa m, received sound pressure level [SPL] = 73-158 dB re 1 µPa). Similarly, there was no reduction in foraging effort for three whales exposed to incidental, unidentified 4.7-5.1 kHz sonar signals received at lower levels (SPL = 89-133 dB re 1 µPa). These results demonstrate that similar to predation risk, exposure to sonar can affect functional behaviors, and indicate that increased perception of risk with higher source level or lower frequency may modulate how sperm whales respond to anthropogenic sound.