Jake had forgotten the punchline.
Does it mean "Jake wanted to say the punchline but he had forgotten it" or "Jake forgot to say the punchline" ?
It means he wanted to say the punchline, but unfortunately he had forgotten it.
However, it is worth noting that I don't know this from the grammar; I know it from the context of the actual situation.
I mean, who on earth tells a joke and gets right up to the punchline, and then simply "forgets" to finish it and walks away? Think about it.