There can be several reasons. Of course, the most obvious is bumping your head, which you can actually do in your sleep and not realize you did. There is also the possibility of an ingrown hair, which will cause a bump and eventually become cyst like and will break on it's own. Best to have checked by a doctor, or walk in clinic. I get them some times and when they break, I apply rubbing alcohol and keep area clean and dry. When I was a teen, had a real big one on my head, and it broke. My mom made me go to school in -20C despite the fact that the doctor told me to stay home and apply warm compress. You may want to try this. A hot moist cloth to the area, to bring swelling to the surface so that it does not continue to be a problem. If it should break, wash hair without shampoo, warm water, and wrap head in towel. And try to keep it aired out and warm, stay indoors, until it heals
In dogs (since this is in dogs) it can indicate an infection, matabolic issue, allergy (usually food), puppy strangles, acne, or that your dog is sensitive to protein so it's best to see your vet to be sure of the problem and how to treat and some of those need to be treated and diagnosed pretty quickly). Here's some info on food for you in case that's a contributor and is always a factor in health. On the analysis link you want to be feeding a 5 or 6 star food (it's how many of us refer to our food in the dog community thanks to this very popular site that has made things so much easier for us and to educate others), be sure to read the reviews of the site and from any others on any food you are interested in OR feeding currently).
www.dogfoodanalysis.com
www.bornfreeusa.org
www.thedogsbone.com
www.dogfoodanalysis.com
www.bornfreeusa.org
www.thedogsbone.com