The story
From an old punishment where when a child was caught smoking a cigarette, they were forced to smoke the entire pack of them, in theory creating an aversion toward cigarettes so they never want to smoke again.
Etymology from Wiktionary, CC BY-SA 4.0.