Close the bedroom door tonight and keep it closed. That isn't the fix, but none of the actual fix works while the bed is still an option, and every time the dog uses it the habit gets a little more settled.
Then let go of the spite idea. Dogs don't poop on your pillow to make a point. We hear "he knows he did wrong, he looks guilty" a lot, and what you're seeing is a dog reading your face and shoulders as you walk in, not a dog remembering what he did forty minutes ago. If you drop the revenge story, the rest of this gets easier, because you'll be looking for a reason you can work on.
Why the bed, of all places
Three reasons come up over and over, and your dog may have more than one.
The bed is soft and absorbent. So is grass, so is a rug, so is a pile of laundry. A dog who already prefers soft surfaces will treat a comforter the same way, and once the smell is in the mattress it marks the spot as a toilet whether or not you can smell it. Many owners notice the same thing with urine, so the page on a dog peeing on the bed may help.
The bed is out of your sight. This one matters most for dogs who were scolded or had their nose pushed in it at some point, even years ago, even by a previous owner. Those dogs learn one thing from the scolding, and it isn't "don't poop indoors." It's "don't poop where people can see." So they go behind the couch, in the spare room, or on the bed down the hall while you're in the kitchen. If your dog sneaks off to do it, this is probably your dog.
The bed smells like you, and the dog is upset about being alone. A dog who only goes on the bed when you've left the house, and who is also pacing, whining at the door, or wet around the mouth when you come home, isn't choosing the bed at random. We'll come back to that one because the steps are different.
And then a fourth reason, which isn't a training reason at all. An adult dog who was reliably clean and starts pooping on the bed, or poops while asleep, or leaves soft or small frequent stools, or is getting older, needs a vet visit before you change anything else. Parasites, a food change, a gut infection, and plain age related loss of control all look like a training problem from the outside. Bring a stool sample. It saves weeks of guessing.
The routine we use
Start a log. Date, time, where the poop was, what the dog ate and when, when the last walk was, and whether anyone was home. Our free accident log is here if you want a template: https://calmdoglibrary.com/tools/accident-log. Within a week you'll usually see that the accidents cluster, and the cluster tells you which of the steps below matters most for your dog.
Clean the bed properly. Bedding on the hottest wash it can take. The mattress gets an enzymatic cleaner, not a scented spray and not vinegar, soaked into the spot and left to dry fully, which can take a full day. Then a waterproof mattress protector. If the smell is in a foam topper, the topper is probably done. A common follow-up is a dog peeing on your bed, which leaves a similar mess to clean up.
Fix the schedule. Feed at the same two times each day, measured, no grazing bowl. Most dogs need to go somewhere between twenty minutes and an hour after a meal, and your log will tell you where yours lands. Pull the evening meal earlier so the last poop of the day happens before you go to bed, not at 3 a.m. on it.
Go outside with the dog. Not "let the dog out." Go. Stand there, boring, until the dog finishes, then pay with something good within a couple of seconds of the last bit hitting the ground. Cheese, chicken, whatever the dog would cross a room for. The timing matters more than the food. A dog who gets a treat at the back door after coming in learns that coming in is what pays. Keep this up for every single poop for at least three weeks. It feels tedious. It's the part that works.
If the dog won't go outside and then goes inside ten minutes later, the dog wasn't empty when you came in. Walk longer. Movement moves the bowel, and a ten minute walk gets a poop out of most dogs that standing in the yard won't.
Supervise or confine, no third option, for about a month. When you can't watch the dog, the bedroom door is shut and the dog is in a crate, a pen, or a room with hard floors. When you can watch, the dog is in the room with you. If the dog starts to circle or sniff in that tight pattern, say the dog's name in a normal voice, go outside together, and pay out there. No "no," no clapping. For a dog who already hides to poop, any noise just teaches more hiding.
Bring the bed back slowly. After three or four weeks with no indoor accidents, let the dog on the bed only right after a confirmed outdoor poop, and only while you're in the room. Door shut when you're not. Give it another few weeks before you trust an open door.
When it only happens with nobody home
If the log shows every incident while you're out, and the dog is otherwise clean, the toilet routine above is still worth doing but it isn't the problem. The problem is the dog's state when you leave. Dogs who panic alone lose bowel control, and your bed is the strongest concentration of your smell in the house.
Don't crate that dog. A panicked dog in a crate can hurt itself. Set up a camera, even an old phone on a video call, and watch the first twenty minutes after you leave. If you see pacing, howling, scratching at the door, or the poop appearing within the first few minutes, you're looking at separation distress, and that's its own project. You'll be working on very short absences the dog can handle, built up over weeks, not on bathroom habits.
A couple of smaller things.
A puppy sleeping in your bed will poop in it at some point. Puppies under about five months don't hold through the night reliably. Crate or pen beside the bed, and an alarm for a middle of the night trip for a couple of weeks.
If you have more than one dog, don't assume you know who. Separate them for a few days and see.
And if the dog has been doing this for years, the timeline is longer than a month. The bed is a well practiced spot. Nothing about that is hopeless, it's just more repetitions of the dog going outside and getting paid for it than a dog who did it twice needs.
If you want the whole plan laid out day by day, with the schedule, the supervision plan, and the bed reintroduction, that's what our guide Calm Home in 21 Days is for.

Calm Home in 21 Days
The 21-day re-house-training plan for adult and adopted dogs: accidents, marking, excited peeing and what to do when they are left alone. Vet-first, reward-based, 6 printable tools.
See the plan →Not sure yet? Take the free 2-minute quiz
Educational content from the CalmHome team. Not veterinary or behavioral advice for your specific dog. If your dog has bitten, or behavior changed suddenly, see your veterinarian and a certified professional.











