It was a Beat Generation moniker, so it was likely coopted by Kerouac and company from the African American community and dates from earlier, possibly originating in the Jazz Age. That's different than the euphemism for a prostitute, which could be even earlier, perhaps the late 19th Century.