When a dog starts to poop in the house you tell them firmly that they shouldn't be doing that and take them straight away outside to potty and tell them that outside is where they're to potty.
Don't bring the dog back into the house until they've pooped outside.
Watch for signs that your dog may be getting ready to poop in the house such as sniffing, circling around in one spot or squatting.
These are usually signs that your dog may be fixing to poop in the house in that spot. If you notice those signs take your dog outside right away even if you have to carry the stubborn dog outside to potty.