Tongue-in-cheek fiction seems to abide by the conventions of an established serious genre, but gently pokes fun at some aspects of that genre, while still relying on its conventions. Examples of tongue-in-cheek films are A Midsummer Night's Sex Comedy, Shaun of the Dead, Demolition Man, True Lies or Hot Fuzz. Note that these films are still faithful to their genre (musical, zombie, action, spy, and police-thriller respectively) and are much more subtle than out-and-out parodies such as Airplane! or Scary Movie.
The Oxford English Dictionary's earliest recorded use of the term was in a 1933 when a Times Literary Supplement review described Shooting the Bull as "a tongue-in-the-cheek march through newspaperdom." It appeared in Webster's Dictionary the following year.
One of the earliest records of the expression is in The Fair Maid of Perth, by Sir Walter Scott in 1828
"The fellow who gave this all-hail thrust his tongue in his cheek to some scapegraces like himself."
Its use was recorded again in 1845 by Richard Harris Barham, the English novelist and poet in The Ingoldsby Legends:
He fell to admiring his friend's English watch.
He examined the face,
And the back of the case,
And the young Lady's portrait there, done on enamel, he
Saw by the likeness was one of the family;
Cried 'Superbe! Magnifique! (With his tongue in his cheek)
Then he open'd the case, just to take a peep in it, and
Seized the occasion to pop back the minute hand.