Generally, to keep the stitch from twisting on your needles, you need to slip the stitch purl-wise; as in, insert the RH needle as if to purl, but just transfer over to the right needle without looping the yarn and pulling through.
As for knit or purl - take into account what your next stitch will be. If you are going to knit the next stitch, your yarn will need to be pulled to the back when you slip. If you are going to purl the next, your yarn will need to be pulled forward. This is to make sure your feed yarn ends up in the right place to make your next stitch.
There are times when you need to slip a stitch knit-wise, but it will result in a twisted stitch. Try it; when you slip purl wise, the loop arcs from back to front, left to right; the right side of the loop is on the front of your needle. When you slip knit wise, the right side of the loop is on the back of the needle.
Let me know if this doesn't make any sense...