Small amounts of Hydrogen peroxide can be used for ear cleaning in dogs but it can not help to treat ear infection especially inner and middle ear infections. If ear infection is caused by the bacteria then use of antibiotics can help. In case of fungal infection, anti-fungus medicines are used. Ideally, take your dog to vet for diagnosis and treatment.
My dog used to have chronic ear infections and vet meds and visits are so expensive. I bought a product on Amazon that does wonders for my dog and he has not had an ear infection in years....if it's the same type of ear infection that my dog has, try Zymox otic ear treatment . There is a cleanser to use weekly which prevent infections and a different product for treating actual infections if he gets one (which I haven't had to use as the preventative one works so well!). I think you can use peroxide if dilluted, but this stuff works and is safe.