Another thing to add to tiggersmom. Is that maybe your not picking up enough poop in your backyard. That happened with us too, but once my mom forced me to clean it up everyday, the flies reduced. And like tiggersmom said, you should give him a bath and clean up the areas where he mostly hangs out. Another thing that works is the photo attached, you can get it at lowes. And you just have to add water. Make sure you hang it out far away from your porch. Just hang it on a tree or something. Because the smell stinks. But it definitely works.
Oh sweetie don't use off on the dog. The flys are attracted to the food and feces so try to keep the area as clean as possible to keep the fly population down. Get the dog on a feeding scheduel so there isn't ever any food sitting out for the flys to get to. Go to your local co-op and pick up some fly spray for horses, try to find one with mostly natural ingredients instead of pesticides. My mom uses the hores fly spray that she buys for her horse on the dogs all the time. I would also bathe the dog in distilled white vinager it will ease the skin and isn't harsh like soap and can help against flys. I would take a fresh pooh sample to the vet just to make sure that she hadn't gotten anything from the flys, like if the flys laid eggs in the food and the dog ate it.
You cannot use off on animals, ever. You can spray the house, but not if the dog jumps up there and walks on it. Clean up the area, I know, ick, but there is a rather large amount of feces and urine in the area if there are that many flies. Give the pup a bath too. Hope this helps, good luck to you.