The first step is to figure out why you have a collection of blood under your nail.
If you hit it, the answer is easy, but sometimes this happens without any apparent trauma. When blood collects, it can cause pressure and pain. Some doctors "drill" a hole to drain it. I've always preferred removing the nail and allowing a new one to regrow.