Our dog is almost 9 years old. She never pees or poops in the house while we're present, she only does it when we're gone.
We recently had a similar problem that we were able to solve. Our dog used to pee/poop in the living room at night after we'd go to bed and closed the door. If we left the door open, she'd jump in bed with us and she wouldn't pee or poop all night. This showed us that the issue was behavioral, not that she couldn't hold it in overnight. We ultimately solved this problem by getting a kennel and having her sleep in there overnight and she hasn't peed or pooped overnight since.
That worked for overnight, but we don't want to have to lock her in her kennel during the day when we're gone at work. What other option do we have to stop her from peeing/pooping in the house while we're gone?
It's worth noting that our dog is not spayed.