One of the possible causes for the scalp sore and hair loss can be infected pilar cyst. It is a benign cyst on the head and neck which is mostly painless but can become painful when infected. Treatment includes topical and oral antibiotics and surgical incision and drainage.
I suggest you to get it examined from a dermatologist to confirm the diagnosis.
It is very difficult to precisely confirm a diagnosis without examination and investigations and the answer is based on the medical information provided. For exact diagnosis, you are requested to consult your doctor. I sincerely hope that helps. Take care and please do keep me posted on how you are doing.
I,ve suffered from a similar problem. Ive always had a tender scalp on and off but about 2 years ago I started noticing my hair was thinning where my scalp was sore primarily. Its been thinning at the top and around the temples. The thinning progressed rather quickly ive had to xut my hair shorter to make it blend. Prior to the thinning my hair would shed these grey flakes like dandruff especially if I was sweating or just finished playing sports. There really isnt a lot if baldness in my family my dad who is 60 has def thinned out and his dad was bald when he was old as well. Im 26 now and think im a little too yoing to be losing my hair. Btw I am African American male. Can my hair thinning be related to my scalp inflammation?