It's a title about which I've often thought - did I make that up? It seems like it's such a familiar phrase.
I think I'm right to be suspicious of claims for the origin of phrases. Recently, Gregg Easterbrook claimed, "The phrase "there's no such thing as a free lunch" originates in" Robert Heinlein's The Moon Is A Harsh Mistress. That struck me as odd -- I read the book, but never got the sense that was the phrase's origin.
According to the site Wordorigins.org, I was right to be suspicious.
The exact phrase, there ain't no such thing as a free lunch, is also first used in the city by the bay in the 1 June 1949 edition of the San Francisco News (although this is claimed to be a reprint of a 1938 editorial so it may be even older, but the original has not been found).
The science fiction fans come into the picture in 1966 with the publication of Robert Heinlein's novel The Moon is a Harsh Mistress. He did much to popularize the phrase and seems to have coined its acronym, TANSTAAFL. More recently, it has become a favorite saying of economists, buoyed by Milton Friedman's frequent use of the phrase.