It could be a number of things.
He may have scratched his penis and now the blood is coming out of the prepuce hole.
He could have a problem with his prostate gland. He could have a prostate infection and the inflammation has caused the prostate to bleed. He could also have prostate enlargement or prostate cancer (don't worry not likely but had to mention). This can be diagnosed with rectal palpation and by taking a sample of the prostate cells for further examination. Treatment is oral antibiotics and possible neutering if he is not already neutered.
He may have a urinary tract infection or kidney infection. This can be diagnosed with a urine test and blood work. Treatment is oral antibiotics.
He may also have bladder stones. This can be diagnosed with a bladder x-ray or ultrasound. Treatment is surgical removal and diet change to prevent recurrence.
There is a very slight chance he has a bleeding disorder and is unable to clot his own blood. If this were the case, you would most likely see bleeding from other body orifices as well. Also they are usually lethargic, have bruising, and have pale gums when they have a bleeding disorder.
I would try to keep him very still. Take a dish towel, and some ice, and hold the ice pack on his prepuce (the pouch where the penis comes out) for 20 minutes straight. If the penis is bleeding, that should stop the bleeding.
If he continues to bleed, then he need to go to the emergency vet.
If his gums turn pale, or gray, he needs to go to the vet right away as that can indicate internal bleeding.
www.VeterinaryPartner.com/Content.plx?P=A&A=2457 more on urinary tract infections
I hope this helps.