How can I use a transistor as a switch?
Maybe what you want is something like this:





Notice that the output is inverted relative to the control signal because when the FET is "on" it behaves as a closed switch making the motor run (assuming that L1 is you motor).

I'm not sure why you have R1 in series with L1, I just leave it there.