Avoid wearing rubber-soled shoes. Rubber is an insulating material, so charge can build up quickly even if you don't feel it. Electricity can't travel back down to the floor because of the rubber insulation, so when you touch a metal object, the electricity takes the path of least resistance, which is through your hand onto the metal.
Pick up your feet when you walk across carpet. Dragging your feet creates friction, which rips stray electrons on the carpet free of their atoms and causes them to cling to you.
Touch a nonconductive surface and hold your hand there briefly before touching metal. This allows electricity to discharge from you slowly without the sudden shock you get when touching a metal doorknob.
Keep the area warm and humidified. Static electricity is strongest in dry air because dry air doesn't conduct a charge, allowing it to build up on objects.