According to Bryan A. Garner, the subjunctive mode (or mood) is a holdover from older versions of English and is now only used in certain circumstances: conditions contrary to fact, suggestions and proposals, suppositions, demands or commands, wishes, and statements of necessity. A lot of the time, the subjunctive is signaled by using "if" or "that." It looks like this:
I: I require that the data be logged immediately.
You: She insists that you tell the truth.
He/she/it: I demand that he give me the information.
We: I beg that we leave soon.
They: If they were to show up, I would leave immediately.
We use the subjunctive mode to signal that the content of a sentence isn't actually true. It's a wish, a possiblity, or something similar:
"If I were Sanzo for a day," Goku said dreamily, "I'd use the Gold Card to buy all the meat buns in China."
As you can see from the above examples, the subjunctive differs from the indicative mode, which indicates that something is either true or an opinion:
"I was Sanzo for a day," Goku said dreamily, "and I used the Gold Card to buy all the meat buns in China."
In the first example, Goku isn't really Sanzo, so he doesn't have a Gold Card. He's imagining the scenario, which is contrary to the facts, and which is why he used If I were. In the second example, Goku somehow actually turned into Sanzo for a day. So in this instance, the scenario is fact, which is why he said I was.
The confusion arises because sometimes writers will use the indicative form ("I was Sanzo for a day" in the example directly above) when correct usage requires the use of the subjunctive ("If I were Sanzo for a day" in the first example), ending up with the casually accepted but technically incorrect "If I was Sanzo for a day."
Okay, so now we know what the subjunctive mode looks like when we're showing conditions contrary to fact, but there are five other circumstances where it should also be used. They are as follows:
Suggestions and proposals
"Bobby can't remember which turn we're supposed to take," Dean said.
Castiel shot him an exasperated glance. "Then I suggest that he think harder."
In this case, the subjunctive is think, not thinks, like it would be in the indicative.
Gojyo knew that if he were to steal Sanzo's lighter, he'd get smacked upside the head with Sanzo's paper fan. Or worse, shot at.
Notice that just like with the contrary to the facts example, this sentence uses were, not was.
Demands and commands
"I insist that he go from our presence at once!" snapped Odin. He brandished his axe at Gabriel, who just rolled his eyes.
In this example, we use the subjunctive go instead of the indicative goes.
"I wish I were able to turn rocks into spring rolls," Goku said. "I'm so hungry!"
"Yeah, well, I wish you were silent instead of a thing that wouldn't shut up," Gojyo retorted.
Here both sentences are in the the subjunctive. Notice that we use were for both I wish I were and I wish you were. In the indicative, the first example would be, "I wish I was," but in the second, we'd keep the were: "I wish you were," since the past tense of the verb "to be" for the pronoun you is were.
Statements of necessity
Bringing the Winchesters to the site of the active Hellgate could be disastrous, but Castiel knew it was necessary that they be there to stop the Apocalypse.
And in this final example, we use the subjunctive be, not are.
So when should you use the subjunctive? If you want to be grammatically correct in your writing or are writing characters who are careful with their speech, you'll want to use the subjunctive for all six of the previous circumstances. If, however, your characters are much more relaxed in their speech, you may choose to use the indicative instead.
For more help and examples, and for further explanations, you can click on the "Sources" links below.
"English Verbs" at Wikipedia.org
Garner's Modern American Usage, 3rd ed. by Bryan Garner
"Indicative," def. 2 at Dictionary.com
"Subjunctive" at Dictionary.com
"Verbs: Voice and Mood" at the Purdue OWL