When you touch certain areas of certain Pokemon, they will do things like electrocute or burn you. Pichu is one of these Pokemon; if you pet its cheeks, it will electrocute you. The PokeDex for the Pikachu line often mentions that they store electricity in their cheeks, so it is logical that they will electrocute you.
You can find a list of areas where Pokemon may have these effects on you as well as their favoured and disfavoured spots here on a page that a Bulbapedia user created.