I find two major causes of headshaking and scratching: food allergy, or need of a chiropractic adjustment. This bold statement is based on assuming there are no fleas, and no ear mites. Assuming there are no critters, and if the ears are clean and smooth on inspection all the way down to the eardrum reveals no earwax, no swelling, or no other abnormalities the chances are very good that your dogs neck needs to be adjusted by a veterinary chiropractor. If the examination of the ear reveals swelling, or infection, then the ear infection needs to be treated, but so does the underlying cause. The number one underlying cause of ear infections in dogs is a food allergy. Sometimes it is as simple as taking away dry dog food that contains grains and byproducts and replacing it with real food. Sometimes it is more complex and may require a food elimination diet. Regardless, headshaking and scratching at the ears all the time is a sign of a problem; it is not something they get in the habit of doing.