It was first used as an interjection in the 19th century: “They marched, and I amongst them, to face the enemy – heads up – step firm – thus it was – quick time – march!”
Then, at the beginning of the 20th century, it began to be used adjectivally, as in: “He was always right on the job, and looking ‘heads up’.”
Then, around the late 70s, it became a noun, probably through shortening of phrases like “heads-up alert” into “heads-up”: “It is regarded as being a heads-up on a sale.”
Source and references: the Grammarphobia blog
Not being aware of the origin, I had to do a little searching and, to my amusement, came across a an entry on wiki.answers that references the A-Team using this in a T.V episode; you can check the link for complete text if you wish, but the following information is all we need to take from that article:
...interesting but you may rest
assured the expression goes back a lot
farther than a late 1970's episode of
M*A*S*H. In fact the show writers may
have been trying to tell us that the
expression was around in the early
50's when the show is set. I don't
know for sure about that but
definitely an older expression.
From there I found a answer I guess I could swallow. It stated that a variation of the phrase exists as "The world's Smallest Violin Playing Hearts and Flowers" - while that doesn't quite ring the same senses, it could go to explain the origins more plainly, namely by giving us a link to Theodore Moses Tobani:
It's also referred to occasionally as
"The world's Smallest Violin Playing
Hearts and Flowers". Hearts and
Flowers, is a song composed by
Theodore Moses Tobani (with words by
Mary D. Brine) published in 1899.
Though the melody for the song
originally appears in Alphons
Czibulka's Wintermärchen compilation.
A purely instrumental version of the
song Hearts and Flowers on violin was
used as an accompaniment to a
multitude of silent films and began to
represent melodramatics and
mock-tragedies. This was a
contributing factor in the origin of
the phrase "Break out the violins" as
a sarcastic expression of sympathy.
The first reference to playing the
smallest violin in popular culture I'm
aware of is in an episode of M*A*S*H
from 1978, in which Maj. Margaret
Houlihan (Loretta Swit) rubs her thumb
and forefinger together and states
"It's the world's smallest violin, and
it's playing just for you."
As you can see, this also captures the usage in M*A*S*H too, which was apparently in 1978. The composition mentioned is from 1899 (according to this source, but 1893 according to Wikipedia), 1893 sounds like it might be the earliest so far.
Best Answer
With regard to the song in which you heard it, the phrase has a double meaning. That's probably why you have the impression that it means too much. The song is Silverchair's Ana's Song (Open Fire) and it's about anorexia (ana is teencode for anorexia). The double meaning is "to the bone" as in deeply (see @Kiamlaluno's answer) as well as in the sense of the skin-and-bone appearance of an anorexic body.