Your dog’s head shaking or ear scratching could be something more serious than mild discomfort. It could be otitis externa or yeast otisis, a painful condition which can spread to the middle ear and may even cause hearing loss if not treated.
Ear Infections (Yeast Otitis) in Dogs – Veterinary Partner – VIN
https://veterinarypartner.vin.com/default.aspx?pid=19239&id=8621491