Static electricity happens more often during the winter season because of the dry air.
There's not too much you can do to avoid getting shocked by static electricity especially when you're outside other than wear insulated gloves when you touch things.
Inside your home you can avoid static electricity by keeping your house humidity up by using a vaporizer to put moisture into the air which will help prevent static electricity buildup.
If you have carpet you can use anti static chemical spray to help prevent static buildup from the carpet and try rubbing furniture with dryer sheets.