Origin of the term "To burn the midnight oil?"

Where did this term come from, and precisely what does it mean?

Also, what is the origin of the term “at the 11th hour”?

I don’t know, for sure; but here is my guess.

“Back in the day”, people used oil lamps for lighting. Oil was obtained from tallow and another source that I can’t think of at the moment (being somewhat caffeine deficient), and from whales. Whale oil was the most desireable oil. It was also the most expensive. To “burn the midnight oil” meant that you had a project that was so important that you burned your expensive oil in your lamp late into the night.

There is a related saying, “Is the game worth the candle?” Again, a candle is an expendable item. Once you use it, it’s gone. So if you’re playing a game, it should be a good game to justify the loss of the candle. In other words, “Are the fruits of your endeavour worth the work you’re putting into it?”

Just to make it a little more clear, to “burn the midnight oil” meant that you had a project that was so important that you burned your expensive oil in your lamp late into the night in order to finish it or get as much done as you can before retiring.

So when someone says they are “burning the midnight oil”, it means they are working late in to the night on something?

Yes.

As for “the 11th hour”, I think that means “at the last minute”.