Get Your Dog Care Questions Answered by Experts
Many animals, besides dogs, will do this.
Most of the time it's done to locate the source of a sound. By tilting their head, they can better determine the source since tilting the ears at different angles/heights allows the brain to use these the sound coming from two different horizontal positions (i.e. left and right ear) to get an idea of direction. They are basically triangulating the sound to determine the source.
Dogs seem to tilt their head more with sounds that are strange, interesting, or high pitch. When they are curious about a sound they seem to use the head tilt more to discern information about the sound. When a dog is actively listening and thinking they tend to cock their head. I believe that this is behaviorally related to trying to figure out the source of the sound. When they are not sure what a sound means and are actively thinking about it, they behaviorally cock their head as if they were trying to determine the source.
A dog may also tilt its head if the sound is hard on its sensitive ears. Sort of like, ouch that sound bothers me, where's it coming from? Thus, again they are trying to figure out what the noise is and where it's coming from.
A final reason a dog could cock his head is that humans think it's so cute that they try to make the noises to make it happen, and when it does happen they pay a lot of attention to the dog, thus further reinforcing the cocking of the head. So, in this case it can be a learned behavior.
Too bad dogs cannot speak English and tell us all of the real reasons. With many questions such as this, us humans can make good theories, but asking the dog, if it were possible would give us the true correct answer.
Hope this helps!