DNA has two strands. How does the machinery of RNA transcription determine which one to transcribe?
I'll keep this short and simple. The direction of transcription (which determines which strand is used as the template) is controlled by the promoter, which is a region of specific DNA motifs at the 5' end of a gene. RNA polymerase binds to the promoter, which orients it on the correct strand and in the correct direction, after which it can proceed to transcribe the gene.
That great little animation is from this website.
To add to canadianer's answer, in fact genes can be found on both strands of the DNA in most eukaryotic cells, in the sense that the sense and anti-sense strands are not always the same strand. The direction is therefore completely determined by the promoter. Furthermore, there are bidirectional promoters.