When your dog is peeing and pooping in the house you need to catch and stop the dog before they poop or pee in the house.
Whenever you spot your dog about to pee or poop in the house redirect your dog to the outside and put on a leash and lead the dog outside and keep them outside until the poop or pee.
If they try peeing or pooping again in the house take them outside again until they get the hint that you'll catch them and take them outside.
You can also give the dog a special treat that is only used when they successfully go potty outside instead of in the house.
Also make a startling noise and say OUTSIDE when you catch the dog peeing or pooping in the house and take them outside right away.
You can also mix lemon juice with some water and spray it on carpet where your dog is peeing and pooping and the dog will avoid the area.