For almost 2 years now, I've been having pains in the back of my head. It happens when I move a certain way & lasts about 5-10 seconds.?

Varies. There are multiple potential causes and I would not hesitate to be seen. One of the more common causes are known as cervicogenic headaches, which often stem from facet joint problems in the back of the neck. There are some good treatment options, so I would be evaluated and discuss within your md.
Many reasons. The list of possible causes of your symptoms are many. Wonder about neck joint (facet or uncovertebral joint) problems. Best to see your doctor for evaluation and possible imaging. Could also be malalignment issue for which Functional Manual Physical Therapy or Chiropractic or Osteopathic Adjustment might help. Hope this was helpful. Best of luck. Dr R.