Well, first of all, not all theists believe in an afterlife. Many (perhaps most) Jews, even devout ones, don’t believe there’s a Heaven or Hell. When Abraham was asked to kill Isaac, did he console himself with the idea that Isaac would go to Heaven? No- because as far as Abraham was concerned, there was no afterlife. His only reason for obeying God’s commandments was that… well, God is Lord of all creation, and a man is obliged to do whatever He commands, without expecting any reward.
No question about it, Abraham’s willingness to obey God without expecting anything in return makes him a most admirable man. In theory, ALL of us should be willing to do God’s bidding without any reward.
That said, to us Christians, the point is moot. Heaven is part of the package that Jesus presented us with. It’s noit as if Jesus told his disciples, “Love one another,” and they yelled back, “Yeah, yeah, yeah, but what’s in it for US?” If WE demanded that Jesus grant us eternal life in exchange for our obedience, we’d be contemptibly impudent. But as it is, Jesus promised it to us, on his own.
So, while we Christians would be duty-bound to obey God’s commandments even if there were no Heaven waiting for us… well, we’re very lucky! Whether we’re worthy of an eternal reward or not, God chose to offer it to us! Thus, we’re not too worried about an angel coming along and telling us, “No afterlife for you!”
Mind you, even if you DO believe in Heaven and Hell, living a virtuous life doesn’t get any easier.