Being that he is 10 years old, I would suspect a health problem.
Have your vet check him out, and take in a fecal sample also. He may have worms? Have a senior wellness examine done on him (blood and urine)...so that you know that his organs are working properly.
For now, after he eats, or when you know that he is going to have a poop take him for a walk or go out to the garden with him and make sure he poops outside. He may also be getting mixed up...sometimes in their old age they get a bit confused.
Have you changed his diet? or started adding anything else to his food?
Is he pooping in the same spot in the house? Clean up the area with a special pet type of enzyme cleaner...and don't let him have access to the spot again.
Gina