My beloved Curie, aka the best dog in the entire world, did that until she was about 2. Some of her relatives supposedly did, too
Debra's solution is the thing that worked. If he does it when you're there, don't even give him access when you're there. It's hard, because they're really great cuddlers, but I'd cut him out of the bed for at least six months and then evaluate again.
Also, are you sure he's actually doing his business outside in the fenced yard? A variation on the "plan" would be to only give him access when you have verified with your own eyes that he has peed AND pooped out there. Only on the bed when empty, in other words. We can get fooled into thinking they've done something just because they went out there, but sometimes they just goof off.