I believe this comes from Robert Browning's famous verse retelling of the medieval legend of the Pied Piper, which is renowned for its humor and vivid wordplay.
When the selfish townspeople of Hamelin refuse to pay the piper for spiriting away the hordes of rats that had plagued them, he exacts his revenge by luring away their greatest treasure, the children of the town.
Hence the modern day expression.
I don't want to get to the end of my life and find that I lived just the length of it. I want to have lived the width of it as well. - Diane Ackerman, quoted in "Newsweek"
Brewer's Dictionary of Phrase and Fable certainly gives "who's to pay the piper" to the Pied Piper: http://www.bartleby.com/81/12907.html, although it also mentions a French phrase. . .but then, the Pied Piper legend existed in Germany before Browning's poem, so maybe the French phrase originates there as well.
There is another phrase, "He who pays the piper, calls the tune," which is almost certainly traditional, and which means that the person who will be paying gets to make decisions.
Interesting. Although the edition of Brewer at Bartleby (which appears to be the 1898 edition) gives it to the Pied Piper, my paperback Centenary Edition published in 1981 says: "Who's to pay the piper? Who is to pay the score? When a piper amused guests at inns or on the green he expected payment for his efforts."
I am not at all in the humor to pay the fiddlers for others to dance. (Je ne suis point d'humeur à payer les violons pour faire danser les autres.)~Molière, La Comtesse d'Escarbagnas, sc. 8, l. 63 (1671)
* * * Since we are destined to live out our lives in the prison of our minds, our one duty is to furnish it well~Peter Ustinov