Some dogs can hear things no one else can and if he appears to be listening this is great.
But, if when he is staring off into space and you call his name and he does not respond, you will want to take him to the vet to get checked for epilepsy, Seizures can be in different forms, from staring to full seizures on the floor.
Medically, the cause of this could only be a seizure-like activity. There are other arguments that since dogs are capable of great perception of ghosts and spirits that the human perception cannot figure out. You can read more on animal behavior or ask a vet to see your dog.