Many possibilities. The most common cause of hemoptysis (coughing up blood) is bronchitis and tearing of small blood vessels that line the airways. Other infections can do it as can blood clots (pulm embolism), inflammation of the lung and cancers of the lungs. A chest x-ray is often very helpful to determine the source of the bleeding.
Get evaluated. This needs evaluation.