Hi there and thank you for your question. My name is Ann and I am a licensed veterinarian and I would be happy to assist you.
If he has not had a dose of dewormer yet, I would go to a pet store and give him a dose of a standard dewormer. Then you can try to add a small amount of fiber to his food to bulk up his feces a bit and that might help it pass through his anus with more ease so that it does not get stuck. If you have access to Metamucil, you can give 1/8 teaspoon daily mixed in with some canned food. This can make the stool softer and more voluminous, which may help with this issue. You can also give 1/2 teaspoon of plain yogurt twice daily to get some good bacteria into the colon.
If this doesn't help, you may just need to have patience and he should grow out of this, but this should help.
I hope that I have answered your question thoroughly... if you feel that I have provided anything less than excellent service, please reply to me first before rating my service and let me know how I can better assist you. Thank you for your question; it has been a pleasure being able to provide assistance. Best of luck.