There could be two reasons for this pain.
2.. Ingrown toe nail
More likely it seems to be due to gout in which there is build up of uric acid in blood leading to inflammation of toe joint.The build up of uric cad results in crystallisation of uric acid crystals in toe joint leading to inflammation.
This condition also develops in obese
people and in people suffering from diabetes
disease or anaemias.
Treatment involves medications.
occurs when edge of the nail goes down into the skin of toe resulting in redness
swelling and pain.
Treatment involves removing a part of nail along with a course of antibiotics.
Consult your doctor who can examine you and diagnose and treat your problem whatever it might turn out to be.