Ambrose Bierce, able to frighten me in ways that few others can match, offers good advice on this topic. Early in "The Damned Thing," during an inquest, a reporter on the stand says to the coroner:
"He seemed a good model for a character in fiction. I sometimes write stories."
"I sometimes read them."
"Thank you."
"Stories in general -- not yours."
"Some of the jurors laughed. Against a sombre background humor shows high lights. Soldiers in the intervals of battle laugh easily, and a jest in the death chamber conquers by surprise."
[THE COLLECTED WORKS OF AMBROSE BIERCE, VOLUME III -- CAN SUCH THINGS BE? The Neale Publishing Company, New York, 1909.]
The key phrase, here, is "in the intervals of battle." I would go further, and say, "before the battle." When faced with a build-up of anxiety, people often joke amongst themselves to break the mood, but when the crisis explodes, it demands their full attention. We see this frequently in Bierce, in L. P. Hartley, and in Elizabeth Bowen's "The Cat Jumps."
This dramatic device goes beyond horror stories. As a teenager, I noticed its power in 1981, when I saw the Peter Weir film GALLIPOLI several times in a cinema, and watched the audience respond to its humour.
Early in the film, when the characters laughed at their circumstances, the audience joined in the laughter. During the middle sequences, the characters, unaware of what lay in store for them, continued to joke and laugh, but the audience had stopped laughing: they could see all too clearly what was going to happen. During the final half hour, nobody laughed; there was nothing to laugh about.
In a horror story, mood and tone count for everything. As the tension builds, we can expect people to behave like people, to laugh at their own intimidating sense of unease, but there comes a point when both readers and characters must feel the weight of dread. When the worst has come to pass, the shock wave of that event should remain ringing in the air for a long while afterwards, or else the fear will be too quickly dissipated.
For an example of dissipation that kills the mood, I always think of the lousy script for ALIEN RESURRECTION. At one point in the film, Ripley stumbles onto her fellow clones, all of them so hideously deformed, so clearly in pain, that out of self-loathing and compassion, she burns them all. An idiot side-kick then stares in disbelief at the bodies, and mumbles, "What's the big deal, man? Must be a chick thing." And so the film dies.
Sometimes, in a story like "Wailing Well," by M. R. James, or "The Travelling Grave," by L. P. Hartley, the initial humour seems to acknowledge the absurdity of a concept, but even here, when things fall apart for the characters, the writers treat their fates with appropriate sobriety. "It's okay to laugh," they seem to tell us, "but stick around, and watch how we develop these ridiculous ideas into something creepy."
So yes, humour does add to horror, but only until the horror strikes. Afterwards, the best response is either shock or silence.