For single notes, the basic rule is that the tie goes in the opposite direction of the note stem. So, if the stem is pointing down, the tie goes on top, and if the stem is pointing up, the tie goes on the bottom. For whole notes, just imagine where the stem would go if there was one, and write the tie on the opposite side. This rule goes back to the idea that ties should connect notes from note-head to note-head.