There is a product that they sell at home stores, it is a yellowish plastic bag that you open, break a capsule, and hang near, but not too near the dog. Can't recall what the name is, but go to the hardware store and tell them the description, they will know. Get the fly one, not the yellow jacket one.
BE CAREFUL WHEN CHANGING OUT THE TRAPS. The fluid smell rancid to attract the flies, they enter and cannot get out. In a few weeks, you will have rotten fly soup in a boulliabase of stinkwater, with maggots to taste. Best thing is to hang it from string, when you want to change them out, just put a trash bag under and cut the string, do NOT touch the thing.
Also, go to a horse/feed/tack store, they make a product, FLies OFF! I think, that is safe to spray directly on the dog, especially the ears.
Good luck.