It sounds like he has overly full or infected anal glands. The glands usually secrete a smelly substance every time your dog poops. But they can get overly full.
If this is the case, your vet can express the glands and solve the problem. If they are infected, he will need antibiotics.
You need to go ahead and see the vet ASAP so you can get him some relief.
Let me know if you still have questions.