What is the correct way to tile a wall when there are existing electrical sockets
Most electric receptacles are installed into the box with long screws that have a special backing washer. The washer is there to hold out the receptacle, so you can loosen the screws until your receptacle is flush with the outer surface of the wall. The face plate is then fastened to the receptacle. In the US, the screws from the receptacle to box are at the top and bottom of the box (or left and right if mounted horizontally) and the faceplate attaches in the center for a typical outlet, and at top &amp; bottom for switches, GFCI outlets, and many newer-style outlets and switches.

If you can get enough extra distance out of those, then you can tile right up to the edge of the electrical box. Here's an example of an outlet that has been set to protrude a bit outside the box:



Note that you should tile around the edge of the box - don't tile right up to the edges of the receptacle within. This way the receptacle can be accessed if needed. The faceplate will cover past the edges of the box.

If your tile layer is too thick for this simple approach, you may need to move your electrical box out. If you have old work boxes (the kind that are installed by clamping or screwing into the wall), you may be able to loosen them and re-mount them once you've tiled. If your boxes are fastened to structure, you won't be able to adjust them - you'll have to cut them out and mount new ones. Because you're redoing the wall surface, this isn't a huge deal. But there is a shortcut available, the electrical box extender:



As you can see, that's designed for exactly your case. It's preferable to have a properly mounted box, but when that is not practical this gives you an easy alternative.