A quick look to the Oxford English Dictionary gives a good guide for such questions.
It lists it's earliest entry that uses the word as such as the 1891 work Slang and Its Analogues Past and Present compiled by J.S. Farmer - so some time in the late 19th century it seems.