Stanley Kubrick’s 1971 film, A Clockwork Orange, is based on the novel of the same title by Anthony Burgess, who once said the phrase came from an overheard Cockney expression, "as queer as a clockwork orange."
In his interpretation, Burgess said "clockwork orange" refers to a person who "has the appearance of an organism lovely with colour and juice but is in fact only a clockwork toy to be wound up by God or the Devil or the Almighty State.”
Starring Malcolm McDowell, the film is set in a futuristic society where he and the Droogs spend their nights getting high before going out for "a little of the old ultraviolence." After being jailed for bludgeoning a woman to death, McDowell's character submits to behavior modification in order to earn his release and he's conditioned to abhor violence. When he returns to the streets, he becomes the victim of his prior victims.