Quick answer
por qué (two words, accent) = why, in questions.
porque (one word) = because, giving the reason.
el porqué (noun) = the reason.
por que (two words, no accent) = rare, "for which".
Side by side
Memory trick
If you could answer with "because", write por qué. If you are giving that answer, write porque. If you can put <i>el</i> in front, write porqué.
Typical mistakes
No sé porque no vino.
No sé por qué no vino.
An indirect question is still a question, so it keeps the accent and the space. The one-word version would mean "I do not know, because he did not come".
¿Porqué no me llamaste?
¿Por qué no me llamaste?
The noun porqué never opens a question. Direct questions always take the two-word form.
Check yourself
Fill in: "Me pregunto ___ no contesta el teléfono."