My chair usually creates a lot of static, so the same happens to me. What I usually do is to touch any big metal object before I get up (my desk is metallic, so I use that) to discharge myself. Another popular trick is to touch the doorknob, faucet, etc with a metallic object, so that the discharge goes from that instead of your fingers. Or you can use an antistatic strap, if it really bothers you.
Regarding the physical processes, when you rub against other materials (e.g. a carpet) you can get electrically charged. That's called triboelectric effect. If you then touch a metallic object, there will be an electrical discharge, like a tiny ray, that goes from your skin to the object and can be painful but not dangerous. If the air is dry (like in an office with air conditioning), you'll build more charge because the humidity makes the air ore conducting and you will slowly discharge with no sparks.