Are you sure it's an ear infection?
Most of the time when dog scratch their ears in not because they have an infection but because they have ear mite!
Look for small black dots inside the ear of your dog..
If it's there you can bet on it that your dog got ear mites.
Go to your vet and ask for Otiderm...it's the best product for getting rid of ear mite...