The subjunctive is a really difficult tense to get to grips with; it is not so much a tense, but a mood. We say that it is most often "triggered" by certain expressions and conjunctions. The most common expressions which trigger the subjunctive are expressions of emotion and wishing, of doubt, denial and possibility, of ordering, forbidding and requesting, and it is also used after superlatives. Specific examples of these expressions are "vouloir que" (emotion), "doubter que" (doubt), "demander que" (ordering) and "le plus grand" (superlative). The most common conjunctions which trigger the subjunctive are phrases such as "avant que", "bien que" and "pour que". With these expressions and conjunctions, it is necessary to learn them off by heart in order to know when to use the subjunctive.
Once you know when to use the subjunctive, you can learn how to form it. Firstly, we take the "ils/elles" (they) form of the present tense verb and knock off the "-ent" ending. What we are left with is called the stem. We then add the following verb endings to the stem: e, es, e, ions, iez, ent.
So, if we wanted to put the verb "aimer" (to like) into the subjunctive, we would take the "ils/elles" (they) form of the present verb ("aiment"), and knock off the "-ent". So, the stem of "aimer" would become "aim". "Aimer" in the subjunctive therefore becomes, j'aime, tu aimes, il aime, nous aimions, vous aimiez, ils aiment.
Of course, there are irregular verbs which do not follow these rules. For these verbs, it is simply necessary to learn them off by heart in the subjunctive. The most common irregular verbs are "avoir" and "etre".
Avoir: j'aie, tu aies, elle ait, nous ayons, vous ayez, ils aient
Etre: je sois, tu sois, il soit, nous soyons, vous soyez, ils soient