How to properly ground a MacBook Pro
tl;dr

Use the extension cord! It is grounded.

Apple's grounding madness

You need your device to be grounded. The charger can be grounded because the metal pin that holds the adapter is (subtly) also the ground:



You need the plug to be grounded too. Obviously a 2 pin/prong plug is not grounded, you'll need one with 3 of them, but even in this case you have to check if the adapter's socket/shoe has metal in it (AKA is connected to the ground), because you can't take that granted at Apple! Just check out this picture from this article:



This is a 3 prong UK plug that has a grounding prong, but they haven't connected it! Fortunately at the extension cord there is a connection. You have to carry that extra 1.8 meter of cable tho...

So at Apple, the rule of thumb is that if it is an extension cord, then the socket is connected to the ground pin so it is probably grounded, if it is the small adapter, then there is no connection in the socket so no grounding for you:



The left picture from this answer shows the difference. The metal is more visible in the magnified picture on the right. 

Hacky solution

Technically you could hack the not grounded 3 prong UK (Type G) adapter (that I mentioned before) to connect the ground prong to the grounding pin as shown in this tutorial. Of course, unless you want to use it with a Type G socket instead of the many other types, you will need to use another (grounded!) adapter to convert it to your desired (grounded!) wall socket.