When taken literally, the colloquial phrases "Knock it off" and "Cut it out" do not seem to mean "Stop what you're doing." How did these two phrases get their current meanings?
Etymology online says knock it off is a request given to an auctioneer to end bidding (by knocking his gavel). While the entry puts the first usage as 1880, the same entry cites a US Senate record of 1834.
Command knock it off "stop it" is first recorded 1880, perhaps from auctioneer's term for "dispose of quickly:"
... if no body bid, after it was cried two or three times, he would say, knock it off, knock it off. [U.S. Senate record, 1834]
The folk etymologies for "cut it out" are worse.
Knock off has numerous meanings, so it’s unlikely that there is one explanation for them all. The OED’s earliest citation in the sense ‘to dispatch, dispose of, put out of hand, accomplish; to complete or do hastily’ is dated 1817, but it has been used to mean ‘To cause to desist or leave off from work’ since 1651. The earliest citation for the imperative meaning ‘leave off! stop it!’ is from 1902.
The OED’s earliest citation for cut it out in the sense ‘to stop doing or using (something); to leave off, do without, omit, drop’ is from 1914. The development from the literal to the figurative is perhaps not too hard to understand.