Thanks for the additional information. It is helpful There are a few possible causes of this behavior including an eye issue, seizure activity or even mice.
I had a dog that looked at the ceiling for about a month, on and off. We had him checked out, and everything was fine. When we went to put up a ceiling fan, we found a mouse nest in the junction box. The dog could hear and smell the mice in the nest. So this is a possibility. We didn't even know we had mice in the house so it came as a surprise.
Some types of seizure activity can cause abnormal behavior, one such behavior is trying to catch flies that are not there others are repetitive behavior such as circling, so that can not be ruled out either. Often a dog will seem to stare off into space or at a wall or at nothing. You can read about these here:
You can read about all types of seizures here: http://www.canine-epilepsy-guardian-angels.com/site_map.htm
He may have injured his eye and developed an ulceration creating a spot in his vision which is making him think he sees something that isn't there. So he sees the spot and moves his head higher to look for it and of course it moves too. Since he can't ever actually see it, this can lead to stress and other abnormal behavior as well.
Since seizures can be the result of toxin exposure, low blood sugar and organ dysfunction, I'd err on the side of caution and have your dog seen if the behavior continues. If your dog hasn't eaten recently when this behavior starts, you might want to put a drop of karo or pancake syrup on his tongue in case he is hypoglycemic. You can read about that here.
I hope this information is helpful to you. If you would like any additional information or have more questions please don’t hesitate to press the reply to expert or continue conversation button so I can address any issues you still have . If you do find this helpful, please take this opportunity to rate my answer.