Probably the most common ear problems in dogs is bacterial or fungal. Treatments for one won't necessarily take care of the other, so having a diagnosis is important. Your dog may be prescribed an ointment, drops or oral medication, or a combination of things.
Mites: Dark brown, brownish red or black appearing waxy build up or discharge from your dog's ears is often indicative of ear mites. Sometimes there's a foul odor which may signal an accompanying fungal and/or bacterial infection.
If you do an internet search about ear mites you'll find a huge selection of options and information, most of them at the ready to sell you a product they just happen to have. Don't bother. None of them can treat all the possibilities the dog may have going on and all of them can cause more harm than good. These are your dog's ears - a vital sense that shouldn't be taXXXXX XXXXXces with.
Other ear problems can be caused by bacteria or yeast (fungal) infections. These can smell particularly bad.
This link has some diagrams and more info http://www.workingdogs.com/doc0079.htm
and even more here: http://www.sniksnak.com/doghealth/earinfections.html
Until seeing the vet, gently wash the ears out with a simple saline solution or ½ and ½ warm water and hydrogen peroxide. Be careful not to let it into the ear canal, perhaps using saturated cotton balls instead. Stop if your companion seems to be uncomfortable with this. There's always the potential that an abscess or infection is causing more pain than might be noted.
The good news is that most ear infections can be successfully treated and it sounds like you caught this early - so you're doing a really good job!