Thanks so much for the additional information.
I assume that he's had his anal glands checked, since this would be the most common cause of discomfort while defecting in a dog this age and size.
If not, then this is definitely something I would pursue. If you're not familiar with these glands, this LINK
provides a great deal of information about them which may be useful.
While you can try to empty these glands yourself, it would probably be best if a vet or vet tech or possibly a groomer did this now since he's so uncomfortable. Emptying these glands externally (which is what most groomers do) is not nearly as effective as internally which is how vets and vet techs perform the procedure.
Additional causes of pain when defecating could be related to his spine where there's compression of the spinal cord or possibly issues with his colon. It's possible that a good physical exam and rectal might detect such a problem or additional testing may be needed.
I've seen some dogs with arthritis
behave as you describe but this is usually seen in older dogs where it's difficult for them to "hold the position" so to speak.
If his anal glands haven't been emptied in a while, I'd start there first.
I might also consider over the counter Aspirin if he's not currently taking any other non-steroidal anti-inflammatory drug. The dose would be 10 mg/lb twice a day given with food to avoid stomach
I might also try adding a small amount of fiber to his diet such as canned pumpkin (NOT the pie mix) at a dose of 1/4-1/2 teaspoon per day to soften the stools in the event that he's uncomfortable producing the consistency of the stools he's currently producing.
I hope this helps and that the problem is easily remedied. Deb