Most probably ear mites. treatment is an applied salve, but is probably only available through your vet - ANY and ALL dogs your dog has regular contact with will need the same treatment.
and BTW, I can highly recommend the Hydrogen Peroxide trick (be sure it is 2% hp by volume... regular medicinal kind)...
We used to have very regular ear mite infestations here... The hydrogen peroxide treatment, used periodically, seems to prevent full-blown infections. We just do it along with regular bathing (about every 3 mo. or so), as an addition prior to bathing. (DO IT OUTSIDE, wear old clothes, repeat till no more "stuff" is coming out of the ear)
Feel free to try it, but I think yours is infected badly enough that a trip to the vet is probably called for...