Originally a theatrical term. 科 refers to stage movements and expressions in classical Chinese opera, 诨 to witty patter. The phrase appears in Gao Ming's Ming-dynasty play 《琵琶记》.
memory
Think of it as the Chinese equivalent of 'stage business' or 'comic relief' - the actor inserts (插) a bit of schtick (科) and cracks (打) a joke (诨).