It's a fine line indeed, and it's probably impossible to draw a hard line like that. Sometimes you're above it, sometimes below.
But the main thing is that you guard yourself from feeling disappointed afterwards. This disappointment comes from a wrong view on the whole situation.
So basically anything that you do extra for the company, you do because it gives you gratification at the moment. Don't expect to be compensated afterwards, because you won't.
But of course compensation for your work is more than money alone, and it's perfectly fine to get gratification from seeing what you created, working on something that excites you, etc.