The idiom tongue-in-cheek is used about a statement that is funny or sarcastic. It is not meant to be taken seriously.
The phrase first meant contempt. By 1842, it got its modern meaning. Early users of the phrase include Sir Walter Scott in his 1828 The Fair Maid of Perth.