This happened with my cat often enough that once I went to pet him and saw him wince from my hand 😢
So after that I started doing the same things suggested here Try touching stuff around your house to see what discharges you, but also what I got in the habit of doing was tapping my cat on the back haunch before petting him. That discharged me in a much more manageable place for him and then subsequent skritches were still pleasant and appreciated.
I’ve tried for years to figure out how to lower the static electricity in my house, but keep coming up empty. I think it’s the combination of rubber-soled slippers, carpeting and anti-static mats in the office. So at my desk, I have ran a thin sliver of tinfoil along the edge and grounded that, so when I sit it discharges through there instead of my computer.
After working in desktop support for a year after college, I realized that people just wanted their problem solved and to not feel frustrated. That realization made my job immensely easier because I pivoted from copying a file in 30 seconds and walking away to talking to them a little bit and letting them feel good after we were done. My ticket closing speed slowed down a little but people felt better and I consistently got positive feedback.