There are many ways to get a yeast infection. For example, you can get a yeast infection if you're taking such antibiotics as penicillin, which kill the good stomach bacteria that keep candida in check. You can also get one if you've been sick or run down, if you're not eating well or if you have hormonal changes (like pregnancy).
You do not need to be sexually active to get a yeast infection.