It’s possible to receive a small and quick electrical static shock through headphones/earphones/earbuds. When using headphones in areas where the air is very dry, it is easy to build up static electricity and possible for your ear to receive a small electrostatic discharge from the headphones. Receiving a static shock from a pair of earbuds does not necessarily indicate an issue with device or earbuds.
This condition is very similar to dragging your feet across a carpet and receiving a static shock by touching a door knob. However, instead of the static charge building up on your body, the charge builds up on the device that the earbuds are connected to.
Likewise, instead of the static buildup discharging through your finger when you touch a door knob, it discharges through the earbuds.
It is important to note that such static discharges are "acts of nature" and do not indicate that one's headphones / earphones are defective. Nor will the static discharge cause harm to the headphones / earphones.