One thing I struggle with as a writer is incorporating humor into a text to lighten the mood or break up the endless cycle of angst (there's not actually that much angst in my writing. Really.). Most of the time, it sounds like it's been forced in, and part of the problem of writing high fantasy is that a lot of the jokes or comments I think a character would make are only applicable in a world with modern English conventions and slang.
Perhaps that speaks to my lack of creativity if I can't come up with a fantasy parallel for some slang. Hmm.
The idea of breaking up one's text exists all over the place. University textbooks and especially school books break up their blocks of text by having lots of information in the margins, pictures, graphs, charts, maps, and background information in their own text blocks. It's all designed with the intent of breaking up the monotony that results from seeing the same thing over and over again. This is the same principle that guides the use of unique chapter headings and drop caps in novels. It breaks everything up. Some people might find that distracting, but for most, I imagine, this is helpful to keep a book from being boring.
Humor goes the same way. It breaks up the tension. The writer for Fullmetal Alchemist stated the same thing when she wrote the series. A lot of the more serious scenes are broken up with lots of humor, and she did it intentionally because she didn't want to have her story bogged down in negativity for too long. This is subjective, of course. Some viewers might view Edward Elric's short complex as being a stereotypical component of shonen anime, but a most astute viewer might see it as a necessary break in what would be an otherwise bleak scene. This isn't used in every serious scene, and it would be hard to give examples without spoilers, but suffice to say, she uses humor very effectively to make the story more engaging.
Go watch Fullmetal Alchemist: Brotherhood (or if you prefer Japanese, "Hagane no Renkinjutsushi (2009)"). Seriously. Go. Now!
Things brings me back to my own writing. I don't know how to do humor, save for my seemingly endless and rapid use of pop-culture references (Take a shot every time Tyler quotes Dragonball Z: The Abridged Series.... two shots if he tried to imitate the voice actor). Actually, don't do that, because then you'd likely be dead from alcohol poisoning.
I try to lighten the mood and break the tension in my work by using what TVTropes would call a "Breather Episode", a short chapter that's light-hearted and tries to distract the reader from the main tension and give them a break, while also providing ample world building and character development to keep it from being pointless. A lot of Dane's wanderlust is shown in these chapters, and I've used that in place of humor to break tension.
It's not for lack of trying that I don't include more funny moments, but I feel that they often fall flat on their faces or they sound stupid when executed. Playing on humor that embarrasses a character for his sexuality (or lack thereof) seems to be one of the few places I've been able to throw it in, and a lot of the rest of it focuses on conflict between characters.
Clearly, this is an area that I need to work on if I want to engage readers and not turn them off from the sheer amount of tension and conflict that's in the book. A good source of seeing how to execute this in a serious context could be looking at TVTropes and the "Crowning Moment of Funny" page of more serious works to see how "the pros" execute it. Of course, some things are harder to emulate than others. What works in Fullmetal Alchemist, for example, may not work in a purely literary medium. It might provide some insight that points in the right direction, however.
Humor is a fine line to walk in my opinion. Making it work without making it seem lame or forced is difficult, and takes a great deal of skill and editing to be able to fit it in.