When has “hanky-panky” come to mean ’sexual dalliance’?
Although use of "hanky panky" to refer specifically (but euphemistically) to sexual dalliance may not have arisen until 1939, as the OED (cited in tchrist's answer) indicates, there are some earlier instances in which use of the term at least suggests instances of illicit or frowned-upon physical intimacy.
For example, from "Perth Prattle Pars," in the Perth [Western Australia] Sunday Times (February 19, 1922):
Parents of budding Melbas and Clara Butts should warily watch their daughters' tutors. Some not only do not know a soprano from a contralto, and in consequence ruin the register, impair intonation, and generally fray the delicate fibre of the throat flute, but are often guilty of hanky-panky which would make a lot of mothers and fathers put on a forbidding frown. One amorous old impostor was won't to hug pretty and buxom girl pupils to his own buzzom, explaining that in that position they would eventually warble a part in Romeo and Juliet duets, etc. Others insisted on less than gym costume that they might observe through the flimsy upholstery the process of proper breathing. There was once an uncelebrated teacher of elocution in Perth who got violently woodened out by the irate brother of an elocuting pupil. This bounder had been, teaching his pet pretty pupil to recite in flimsy bathers.
From "The Bull's-Eye and Some Outers," in the Bathurst [New South Wales] Times (February 21, 1922):
More murders in Egypt. Things have always been pretty strenuous in that ancient land since Antony and Cleopatra played up hanky-panky there a few centuries ago.
From F. D'A. C. De Lisle, Brides of the Bush: An Australian Story of the Pioneering Days, serialized in the Portland [Victoria] Guardian (July 7, 1932):
"I dassent! I dassent!" she muttered; "Ben 'ud kill me! I know he'd knife me for 'em! No, missy, I can't help yer to clear, it's more'n my life's worth. But I'll tell yer what I will do, though." She turned with a ghoulish leer, to Agnes. "Yer say ye've only been married a fortnight, so I s'pose yer honnor, as yer calls it, is mighty precious to yer. This 'ere bloke wots kidnapped yer might come his hanky panky now he's got yer alone in this lonesome place." She dipped down into some capacious pocket in her skirt, and withdrawing her huge fist held it towards Agnes, saying— "What'll yer give me for this [a loaded Browning automatic pistol]?"
From "The Indiscretion of the Mayor: It Opened Up the Way to happiness for Two Young Lovers," in the Adelaide [South Australia] Chronicle (December 6, 1934):
"Now, Peggy, you understand once for all," said Mr. Purdom, the Mayor of Widcombe, with severity, "that there's no hanky-panky tonight with Jimmy Stevens. I've forbidden you to marry him, I've forbidden you to dance with him, I have also forbidden you to speak to him. Tonight you will kindly remember that you are the Mayoress of Widcombe, and that you dance with aldermen, or those who are likely to be aldermen."
Still a close review of Elephind newpaper matches for "hanky panky" from the period 1910–1939 indicates that the vast majority of instances of the term used it in the sense of "flimflam" or "hocus-pocus" or "hoity-toity"—but not in the sense of "hootchy-coochying with a hotsy-totsy." It may also be relevant that a hugely popular musical comedy review titled "Hanky Panky" ran for years in various parts of the English-speaking world during the mid-1910s and after. I don't know whether that show made the term less disreputable or more, but references to it certainly appear in a lot of newspapers of the period.
The OED has 1939 for the first cited occurrence of the secondary meaning:
- Sexual activity or dalliance, esp. of a surreptitious nature.
Their earliest citation of this extended sense is from George Bernard Shaw’s play, Geneva:
- 1939 G. B. Shaw Geneva I. 5
She: .. No hanky panky. I am respectable; and I mean to keep respectable.
He: I pledge you my word that my intentions are completely honorable.
So that’s around a century later than its first documented occurrence in the legerdemain or sleight-of-hand sense.