I know what it refers to… but what does it mean? How does cutting off one’s nose spite one’s face? Where did this expression come from? I searched around but didn’t see any good explanations. This has been driving me nuts for years…
It means doing something out of anger which brings as much or more harm to you as to the object of your anger. The notion of being angry at your own face is a bit odd, but you get the idea.
Spite as a verb means to annoy, offend, or treat maliciously. As a noun it means petty ill will or hatred.
If I hate you, particularly if I hate you because something you have done to me and I want to take my anger out on you in some way, I might do something out of spite for you. For instance, I might slash your tires. I would then be said to have slashed your tires to spite you.
If I hate my face, particularly if I hate the way my nose makes my face look, I might be tempted to cut it off out of spite. That would be a foolish thing to do because as Tycho Brahe can tell you, a face with no nose is something only a mother could love. Hence the saying: “Don’t do something out of spite that will only make matters worse.”
I disagree with the interpretation “doing something … which brings as much or more harm to you as to the object of your anger.” That is more closely a paraphrase of the saying “Don’t piss into the wind.” 
Hope this helps.
One of my favorite versions of this quote was mentioned in a text book I once read, War, Peace and International Politics by David W. Ziegler.
He quotes Thomas Schelling:
of the Jewish actress back in the fifties who had found that her Semitic features were something of a barrier to stardom. So she got some plastic surgery in attempt to mask her ethnicity. One of her friends commented on seeing her for the first time after the operation, “I see you’ve cut off your nose to spite your race.” “That’s right,” she responded, “now I’m a thing of beauty and a goy forever.”
;j
But, KneadtoKnow, the phrase very clearly implies that the action in question makes matters worse FOR YOU.
Now about “pissing into the wind.” I usually interpret this as synonymous with “doing something without thinking about pretty obvious negative consequences,” but, possibly due to that Jim Croce song, it is sometimes taken as “doing something that will bring down the wrath of someone more powerful than you.” Which do you all think is the more commonly accepted meaning?
Cher3 is correct on both counts. However, when I was growing up, the phrase was always in the indicative: “you don’t piss into the wind”. It was not advice, literal or metaphorical. It was a statement to the effect that a reasonably intelligent person doesn’t act contrary to common sense.