The biggest key to writing humor for a story is to understand your character's sense of humor. Everyone has a different way of making jokes and the jokes should reflect your character's personality and the way they see the world and think. You don't really need a setup for a punchline to make a joke outside of a comic strip format: the whole story is your set-up. If you teach yourself, and through that, your character, to pick the humor out of a situation, or to figure out how to spin the situation into a joke, you'll be better off than just making jokes out of the blue that don't really seem to relate to the situation.
A few examples that I've written; (just to give you context of how this can be used)
“Fortunately your ancestors did half the marketing for us. I’ll bet money there aren’t many other artists with your last name on the market right now. Where exactly does ‘Palmero’ originate from, if you don’t mind me asking?”
“It’s Spanish,” I smooth the front of the binder with my left hand, but keep my eyes on his face, “I’m Mexican and Navajo on my dad’s side - just plain Mexican on my mother's.”
“Is that so,” he says with a smile, “speak any Spanish?”
I nod, “I’m out of practice though.”
“But that increases our options ten-fold, that’s good to know. If you happen to be able to dance on aerial silks or do a backflip, you should also not hesitate to mention that....”
*
“Excuse me, Mr. Man,” I nag, hands on my hips as he comes in sipping a cup of coffee, “but how exactly do you expect me to get up there in pumps?”
“Well, there are two or three ways.” He smirks, setting the cup down on his desk, and wiping the condensation onto his cable-knit sweater. “I can put my hands together and help you step up or you can take the heels off and climb up like a five-year-old in Mickey Dees play place.”
I roll my eyes.
“First of all, that’s only two ways, and I’m pretty sure my shoes would stab straight through your palms if we tried the first one, and you’d have to spend the rest of the day looking like Christ.”
“Just take the shoes off and I’ll help you put them back on once you’re seated.”
I shake my head, but step out of the heels, and climb up onto the chair.
As Shannon slides the right shoe back onto my dangling foot he quips:
“If the magic slipper fits…”
“Hah.”
“It works! We won’t have to remove any toes.”