Elsewhere it has been shown how the expression, “That’s the ticket,” arose from a mispronunciation of etiquette.
But the French word itself means “ticket,” among other things, and in Old French was used to designate the ticket that prescribed a soldier’s lodging place, his billet.
Just how the sense became transferred to prescribed conduct is not known.