The standard format has five lines: the knock-knock (indicating a door has been struck to gain attention), an enquiry ("Who's there"), a response, usually involving a name (to set up the pun), a request for clarification and the punch line, which inevitably involves a punnish misusage of the word set up during the response.
Some examples:
Knock knock
Who's there?
Keith
Keith who?
Keith me, my thweet printh
(Kiss me, my sweet prince)
Knock knock
Who's there?
José
José who?
José can you see by the dawn's early light?
(Oh say, can you see by the dawn's early light? -- from US's national anthem.)
Knock-knock jokes occasionally employ a pun on a common noun.
Knock knock
Who's there?
Orange.
Orange who?
Orange you going to open the door?
(Aren't you going to open the door?)