The reasons for this can either be medical, or behavioral. Medically, the dog could be licking itself excessively because of a skin allergy, dry skin, irritation on it's skin. Usually, there is a skin allergy that we don't notice, so it's a good idea to give your dog Benadryl at 1 milligram per pound of dog's weight, three times a day. You can also apply camomile on the skin where the dog keeps licking itself to soothe the area.
There are also behavioral reasons, most commonly due to anxiety. The dog can also do this to gain attention, or to get more affection.
You can start by giving Benadryl and applying Camomile, but there is always the possibility that this will not control the situation. Sometimes, dogs will cause secondary infections to themselves by causing sores where they constantly lick themselves, so you will need to watch out for that.