These days this expression is used figuratively to mean “work late into the night”. But it doesn’t take any great stretch of the imagination to work out where it came from. We might not actually burn oil today, but in the past, of course, any work done late would have needed an oil lamp or a candle to see by, and this is of course where the expression originated.
Historically, we know that it was used in the early 1630s, probably much earlier. We find a reference to this phrase in the most famous work by poet Francis Quarles, Emblems (published in 1635).
We spend our mid-day sweat, our mid-night oil,
We tire the night in thought; the day in toil.
(Book II, following Epig. I)
Given the prevalence of candles around the world, you might have expected the expression to be a common one across many languages. However, it seems that in German one is more likely to say simply bis spaet in der Nacht arbeiten – which simply means “to work until late at night”. In Italian the expression fare la nottata, which translates as “make a long night”, is popular.
Welsh deserves a special mention for its idiom, because of the image it conjures up: gweithio tan berfeddion nos, meaning “work till the bowels of the night”.