Marking and eliminating are different behaviours, and shouldn’t be confused. Dogs leave their mark to claim territory or to vie for the role of “master of the house.” If you should notice this behaviour indoors or out, strengthen all obedience commands immediately. Your dog should have no doubts about who’s in charge.
If your dog continues his “territorial marking,” consult your veterinarian. If he’s not spayed or neutered, you may want to consider the procedure. It usually has a very positive effect on this type of behaviour problem.