There are a lot of reasons your dog may be eliminating inappropriately, but because serious illness or injury can be a primary cause, it's always a good idea to talk to your vet about the problem before attempting any at-home treatment.
Some common reasons dogs may poop in the house include:
The medication used to treat certain conditions may also be behind your dog's accidents, so if your dog is taking drugs, talk to your vet about that medication's possible side effects.
If your pet is still a puppy, expect more than occasional accidents in the house. When dogs are young, they're still learning how to control their bowel and bladder, a skill they don't generally master until five or six months of age.
If your puppy is having trouble learning to defecate outside or in a designated area, strive for consistency, encouragement (never punish), and make sure they get outside frequently.
Along with youth, other reasons a dog may poop in the house include separation anxiety, a preference for certain surfaces (like carpet or tile), a change in schedule or in the household, even a dislike of rainy or cold days.
A change in your dog's diet -- a new food or a change in the amount of food -- can also cause a dog to poop in the house, especially if the dietary change triggers diarrhea. Also, some dogs just need to poop soon after they eat. If yours is one of them, you may need to feed your dog only when you're home to take him outside after he has eaten.
Talk to the vet about your dog's diet; your vet may recommend switching your pooch to a low-residue or easier-to-digest diet to help with inappropriate elimination.