Obviously, you need to rehearse the joke until it goes smoothly. Listen to tapes of your delivery. If you trip over the words, rewrite them to make them easier to say.
Even if you are reading the rest of your speech, this has to be memorized to work or it will seem as if you do not have enough sense of humor of your own so that you need to insert someone else's. An anecdote does not have to be memorized if you can simply hit the main points and remember the punch line.
Speak clearly, strongly, and deliver the punch line with energy while you smile (unless deadpan is appropriate). And remember that when you are done, do not return to giving your speech until the audience's laughter has died down.
And if you have done your homework and rehearsed adequately, a well-developed sense of humor will never leave you without a good ad lib in an awkward moment.