I'm sure there are hundreds of potential reasons as to why you're coughing up blood. It's impossible for internet-folk to diagnose the problem. Primarily because none of us are trained professionals and even if we were, we can't exactly examine you from here to further to determine the problem.
There are lots of websites that will tell you possibly causes if you type in the symptoms. Failing that, contact some medical professionals (see Jamesey's post) or go to your doctor.