According to The Oxford English Dictionary, it is probably derived from the German noun 'Schmeck', meaning a 'taste'. It has meant heroin or a small packet of the drug since the 1940s. We see the same sort of usage in saying that something 'smacks' of something else, as in "That smacks of dishonesty to me."