The law regarding medical marijuana is still developing, but so far it looks like employees can be fired for marijuana use, even if they have a legally valid prescription for the drug and don't use it at work. Medical marijuana is legal in more than a dozen states, with written authorization from a doctor. However, this protects you only from criminal prosecution under state drug laws: It doesn't protect you from federal drug laws, nor does it protect you from discipline or termination under your employer's policies. Courts in at least two states that recognize medical marijuana, California and Oregon, have ruled against an employee in this situation.
For more information on how much employers may inquire about, or consider, what you do in your own time, see Nolo's article Off-Duty Conduct and Employee Rights.