Tea tree oil has shown both antimicrobial and antifungal activities in scientific studies when used at appropriate concentrations. Some dogs (and humans) have a predisposition genetically to have allergic reactions to it. There has been reports of neurotoxicity when used in high concentrations. If it were my dog I'd would want to smear a small amount on the abdomen first and see if a contact dermatitis reaction occured.
I have used tea tree oil in the past on my dogs as a substitute for bitter apple to prevent the dog from licking off Antibiotic salve on minor wounds. My previous dog actually developed a taste for bitter apple. A thin diluted smear of tea tree oil on top of the salve prevented licking.
Lavender oil smells nice, but has no demonstrated healing properties. There is one scientific study where by scenting a car with it had a tranquilizing effect on dogs (and maybe the driver too?) that were otherwise excited when traveling in a car. Or aeromatic therapy.
A scan of the scientific literature did not turn up any references to Rosemary extracts as having anti-pain properties. However there was an article indicating some anti-bacterial properties, and it seems to scare twospotted spider mites off of greenhouse tomato plants. Whether it would have such an effect on canine ear mites (if present) is unknown.