You appear to be describing sundowners syndrome - a form of cognitive dysfunction in dogs and humans. It's conjectured that the dark and quiet of night magnifies the sensory loss in these patients which results in their anxiety and subsequent aimless wandering. Other indications of cognitive dysfunction include disorientation, changes in social and interactive behavior - becoming "needier" or, conversely, more aloof - changes in locomotor and sleep cycle behaviors, and loss of housetraining.
Unfortunately, this is a progressive disorder and often vexes caretakers unable to control inappropriate behavior. If additional medical problems exist - brain tumor, e.g. - seizures may arise and prompt the need for anticonvulsant drugs. You may find that a prescription benzodiazepine such as alprazolam (Xanax) will be helpful for controlling his anxiety, panting, and pacing and so discussing the use of such a psychotherapeutic drug should be discussed with his vet.
Ancillary care involves physically and mentally stimulating exercises such as swimming, massage, and range of motion exercises, encouraging relaxation, ensuring that he is taken out frequently to minimize the cost of elimination "mistakes", encouraging reestablishment of daily cycles by feeding at regular hours and at least a few hours before bedtime, and administering the alprazolam before bed. Specialized diets rich in antioxidants may be of value such as Hill's Prescription Diet b/d. The monoamine oxidase inhibitor selegiline (Anipryl) is the only drug licensed for use for the treatment of canine cognitive dysfunction in the States. Many of us aren't impressed with the studies supporting its use, however.
Cognitive dysfunction in dogs is just as difficult to manage as is Altzheimer's in humans. I wish I had some magic for him. Please respond with further questions or concerns if you wish.