Answer: Our auditory system (the olivary nucleus) differentiates the signals that arrive in each ear.
There are two major calculations that our brain processes when a sound originates from one side of our body: the interaural level difference (ILD) and the interaural time difference (ITD). These two differences are used by the brain to localize the direction from which a signal originated.
The ILD refers to the difference in the volume of the stimulus that arrives in one ear and the volume of the stimulus that arrives in the other ear. Consider you are standing in a room, and a loud musical note is played on your left. The sound waves will travel towards your left ear without obstruction, and this is perceived as being loud. On the way to your right ear, many of those same sound waves are blocked by your head. As a result, the sound that the right ear hears is less loud. The brain calculates the difference in loudness to determine that the sound originated from the left. The lateral superior olive processes differences in stimulus intensity.
The ITD refers to the difference in timing that is perceived when a sound stimulus is presented. If that same musical note is presented, the left ear will receive the signal microseconds before the right ear receives the signal. This tiny delay in when the ear hears the sound is another calculation that the brain uses to determine that the sound came from the left. If a sound is made directly 90 degrees to the left of the head, the delay between the two input signals will be around 700 microseconds. The medial superior olive processes these time differences.
In a room with no surroundings, it is very difficult for an average person to determine if the sound originates from above or below us, but relatively simple to determine which angle around our head the sound comes from. The shape of the outer ear (pinna) allows us to roughly identify if the stimulus comes from the front or back.