Cats and dogs are empathic creatures. They pick up our feelings, and they reflect them back to us. That is part of the reason why they are such wonderful companions.
When you go through something stressful, your pet is bound to notice your stress and respond to it. Unfortunately, stressful events are an unavoidable part of life. My advice is to focus on recovering from your surgery. When you feel better, your dog most likely will, too.
That said, to keep my attorney from getting mad at me, I should point out that there is a chance your dog is suffering from a genuine medical problem. Stressful events can unmask developing health issues in pets, just as they can in people. So, to be safe, you should take your dog to the vet for a checkup if you are able, or ask a friend to take him for you.