If you think maybe he is anxious or has reason to be bored, do what Cesar Milan says, walk, walk, walk him a tired dog is a happy dog! Otherwise, if he is outside a lot, perhaps he just hates flies or they have been biting him, there are some sprays you can buy to keep the bugs away and keep him happy, consider all natural bug sprays. Good luck. V
I am having similar issues with my dog and finally decided to look into this behavior, It is troubling because he'll have sudden fits where his ears start twitching and then goes after his tail. I tried exercise, but that doesn't seem to be the answer because he'll do it after I walk him for 2 hours or run him 4 miles. Bones and treats bore him and do not prevent this behavior. I literally have to hold him to make him stop. Anyway, I looked it up on the internet and it is believed to be epileptic seizures and is something you NEED to have checked by a vet because this is a neurological problem. If you Google "Imaginary Fly Biting and Dogs" you'll find out SO much! Good Luck!
It is something to do, he is probably bored, or neurotic. Also, just because you can't see what he's biting at, doesn't mean it is imaginary. He could see little gnats, or specks of dust floating on the air, or even reflections of light. (The reflections are my terrier's favourite thing to get nutty about!) If you haven't already, try giving him a chewy bone or something that will keep him occupied and see if it is just that he has nothing better to do.
Have you checked him for fleas. Dogs also have heightened senses so he may be smelling something you can't see