I don't believe it is because he does not know any better because he will often do it despite the fact he has recently been outside.
Did you ever punish him for eliminating in the house? If so, the reason he is not eliminating in front of you is because he gets punished when he does but nothing bad happens when you're not around. Yes, you are correct, any type of scolding after the fact is useless.I know there is no use in yelling at him or trying to punish him if you can't catch him in the act.
There are 2 main aspects of housetraining: 1) encouraging a preference for substrate and location, and 2) encouraging inhibition of elimination until the appropriate substrate and location are accessible. The latter is largely dependent on cognitive and neuromuscular maturation of the dog.