This is an infection of the fingertip called paronychia. This is usually caused by a bacterial infection due to a break in the skin near the nail. Individuals who bite their nails have a higher chance of getting such infections.
The greenish collection seen is pus, which is a result of the bacterial infection causing necrosis of tissue. The painful and red areas surrounding this pus collection is due to inflammation caused by the infection.
The recommended treatment for paronychia is surgical debridement and drainage of the infected tissue and treatment with oral antibiotics until the infection settles. In severe infections, part of or the entire nail may have to be removed to facilitate the clearance of infection. Early treatment is key. If left alone and untreated, such infections may spread or even affect the underlying bone, causing a much more complicated problem - osteomyelitis, or bone infection.