Its common for your dog to shake his head when there is discomfort in his ears. This could be due to a buildup of wax or more commonly an infection of the ears.
A young Staffordshire Bull Terrier shaking its head
If you notice shaking of the head you should check your dog's ears, and contact your vet. For information on how to check your dog's ears click here.