Due to a lack of humidity in the local environment, your cat's fur builds up quite an electric charge. Then, when you pet it and add friction to the mix, you and your cat feel shocked.
The level of pain experienced by the cat in such conditions is not alarming. While it is undoubtedly an unpleasant feeling, it is more of an annoying/surprising experience rather than a painful one.
The central cause of the static electricity in your cat's fur is the low humidity level. Therefore, the best possible way to fix this issue is to raise the humidity levels in your home.
Suppose you are not in a position to make home improvements. In that case, there are other ways in which you can reduce and even remove static electricity in your cat.
2. Cat-Centered Methods of Removing Static Electricity