The expression to knock off has many senses, all of them colloquial. Below is the OED entry. Sense 12 is the only one relating to sex. Its first example is from 1942, which suggests (from what the OP says about its use in America) it may have been introduced to Britain by American servicemen arriving about that time. No mention is made anywhere of its referring to masturbation.
to knock off - OED entry. (Only the most recent example of each sense is given, though some date from as early as 1616. Sense 1 is found in Shakespeare.)
- trans. To strike off by or as by a blow; also fig. to knock off a person's head , to ‘beat’ or surpass him.
1862 Cornhill Mag. June 655, I could knock his head off in Greek Iambics.
- To cause to desist or leave off from work; to discharge or dismiss from employment, to ‘lay off’.
1955 Times 9 June 8/3 The Cunard company put the main restaurant at his service and the staff captain ‘knocked off all the men from their duties’.
- intr. To desist, leave off; to cease from one's work or occupation; slang to die.
1916 ‘Boyd Cable’ Doing their Bit iii. 49 The factory was knocking off for dinner as we came away.
1969 M. Crouch Essex ii. 28 One who has just knocked off for his tea-break.
- trans. To stop, discontinue, give up (work).
1885 R. Buchanan Matt viii, He at once knocked off painting for the day.
- To dispatch, dispose of, put out of hand, accomplish; to complete or do hastily; spec. to write, paint, etc., in a hurried and perfunctory fashion. colloq.
1970 W. Garner Puppet-masters xv. 124 Look, you could knock off a few hundred words on Baxx without so much as scratching the surface of your magnum opus.
- To strike off, deduct from an amount or sum.
1972 Daily Tel. 30 Mar. 19/2 The gloomy assessment..knocked 12p off ICI's share price in London.
- Cricket. Of batsmen, to score the runs requisite for victory, or to oblige (a bowler) to be taken off by scoring heavily from his bowling.
1963 A. Ross Australia 63 18 Pullar and Cowdrey knocked off the 49 required to win without actually being separated.
- [imp. use of 3.] knock it off! : leave off! stop it!
1961 J. Heller Catch-22 (1962) xxvii. 294 ‘Hey, knock it off down there,’ a voice rang out from the far end of the ward. ‘Can't you see we're trying to nap?’
- slang. To steal, to rob. Also transf.
1973 A. Hunter Gently French iii. 24 Just met a bloke..in the nick... Him what was in there for knocking-off cars.
- slang (orig. U.S.). To kill; to murder.
1973 C. Mullard Black Brit. i. ii. 24 In one village a white launched a murder campaign because ‘he liked knocking off blacks’.
Underworld slang. To arrest (a person); to raid (an establishment).
1969 R. V. Beste Next Time I'll Pay xi. 157 You're the sort who'd knock off his mother because she hadn't got a lamp on her bike five minutes after lighting up time.
slang. To copulate with, to seduce (a woman).
1974 Times Lit. Suppl. 11 Oct. 1109/4 Knocking off his best friend's busty wife during boozy sprees on leave in Soho.
Blockquote