Thanks for the query.
Severe dandruff could indicate dandruff itself which is significant or can indicate beginning of some other skin condition like Seborrheic dermatitis or Scalp psoriasis. Based on your description of pain it looks like a superficial bacterial infection usually caused by staphylococcus aureus. Sometimes they co-exist with fungal folliculitis.
Next Steps
Kindly consult a dermatologist for exact diagnosis and a precise treatment plan. It is also important to prevent their relapse once you have got it cured. A decolonization regimen suggested by your doctor will help.
Health Tips
Consider using an antifungal shampoo on alternate days.