A quick shake after a swim or a nap is normal. Repeated shaking, tilting the head, rubbing the ears on the floor or scratching at them is a sign that something is bothering your dog's ears.
Dogs' ear canals are long and L-shaped, which traps moisture and debris, so infections are common, especially in dogs with floppy or hairy ears and in dogs that swim. Most ear infections are a symptom of an underlying cause, most often allergies. Treating the infection without addressing the cause means it tends to come back.
Look inside the ear flap: healthy ears are pale pink, clean and don't smell. Redness, swelling, a brown or yellow discharge, or a yeasty or foul smell all point to infection.
