What is the relationship between hemoptysis with age and gender?

None directly. Coughing up blood can be from inflammation of lungs, breathing tubes, cancers, other. The problems that can cause this are more common as you get older (but not related to age per se), and not directly related to sex. Can vary with smoking history, infections, some autoimmune disorders (more common in women), etc.