Almost all stun guns have a safety switch or a safety pin.
I mean, I know there's going to be a button you can press to stun your attacker. But I don't want to be carrying a stun gun with me to work (I don't have a car) and while I'm working, end up being stunned by it on accident. I'm wondering if they typically come with an on/off switch.
I strongly suggest you do some extensive research. Stun guns come in a vast variety of sizes and capacity (the electrical equivalent force). Some, the majority, actually have a safety switch to minimize accidental discharge. You must also become aware of the (in the USA) city, state and county ordinances and licensing requirements. For everyone's safety, including your own, you should attend classes on the use of such weapons. In most classes you will be subject to being shot with one so you know what it feels like. That helps make your judgement as to use or not use more realistic. You must remember, many folks, because of unknown health reasons, or the young and elderly, can be killed by a stun gun. I am personally aware of a few cases where the owner of a stun gun, who was not well versed or trained in its use had the gun taken away by a mugger who in turn shot them with their own stun gun.