I'd rather kill a joke rather than be disrespectful. The sooner you learn this, the happier your life will be and more people will enjoy having you around.
I've found that the best way is to explain myself like I'm 5. If somebody gives me a weird look after I give a dead pan joke, I'll stop what I'm saying and go "oh, sorry, I'm a very dead pan person and I was trying to make a joke, I guess it didn't come off that way, my mistake!"
Sure, at first it sounds weird or unnatural but I find that this has worked out better for me rather than staying quiet and blaming them for not appreciating my sense of humor.