Being stung by a nettle is painful because the sting contains an acid.
Rubbing the sting with a dock leaf can relieve the pain because dock leaves contain an alkali that will neutralize the acid and therefore reduce the sting.
Bees and ants also have acidic stings, so dock leaves should help, but other alkalis, such as soap or bicarbonate of soda, are usually better.
However, a dock leaf is useless against wasp stings, which contain an alkali.
This is unfortunate because wasps are nasty little critters whose sole aim in life is to ruin picnics and barbecues. If you want to neutralize a wasp sting you should use an acid such as vinegar.
The only problem is that you’ll smell of pickles for the rest of the day.