Not sure if this is quite right but I read that its an analogy for the idea of promising rewards that will never come. For example, a school teacher promising kids a pizza party if they all stay quiet for the rest of the day. Then forgetting about it for the rest of the time he/she has as their teacher. I'm afraid its exact origin remains a mystery to me.
Well there is a video game called Orange box. In this game are several games. Team fortress 2 is one of the games, but the expression comes from a different game in orange box called portal. You go through a very difficult sort of obstacle course test and when it is complete they say they're going to give you cake. Lie.
It's from the 2007 video game "Portal" which comes bundled with some other games, but can be bought seperately.
The main character is a lab rat for a secret science company that creates numerous inventions. Your leader is an evil robot who promises to give you cake if you complete missions while testing the company's inventions.
You find later on that "the cake is a lie" and the robot is planning to kill you by the end of the game. The main character escapes death and goes out to destroy the robot.
Think that's the simplest way I can explain it so it makes sense.
SPOILER: The ending shows that theree reaally was a cake! Though definitely not for you.