What does it mean when your hand hurts after writing with pen?

Few things. It could simply be pain due to writing too much or gripping the pen too hard. Other possibilities includes tendinitis, carpal tunnel syndrome, and arthritis (usually osteoarthritis). These are not generally not hard to diagnose. Start with your primary care physician. If no help, see a rheumatologist.