When one of my pooches started scratching his ears and seemed bothered by something, a trip to the vet showed that he had an ear infection. He also had a lot of dark debris in his ears (another indication of some sort of problem). The vet prescribed Otomax, which is an ointment that is administered into the ear. I had to clean the dog's ears first with an ear wash, and then administer the ointment (by drops) into the ear canal.
This ointment was used for about one week, and it seemed clear up my pooch's problem very well. This is a prescription drug (gentamicin sulfate), so it must be prescribed by your vet. But if you find that your dog is having itching problems with his/her ears and has dark matter in the ear, it may very well be an infection that the vet should look at and treat. Otomax seems to be a pretty good drug for clearing up this sort of problem.
I don't like drugs very much, either for humans or animals, but sometimes we just can't get away from using them. Otomax seems to have done a pretty good job of clearing up my dog's ear infection. Check with your vet if you have a dog with ear problems.