The reason I ask is because it sounds as though it may involve your occipital nerve (not optical nerve). My husband cause damage to his due to his weight lifting. Everytime his heart rate would go up ( even slightly ) he would get a blinding pain that would last for a few seconds he had to keep him self from getting excited (ie; exercise, yelling, sex) for a little over a month. He was fortunate and it was able to heal it self.
I, on the other hand, damaged mine in a car accident. I get muscle spasms in my neck that irritate the nerve. Mine tend to last anywhere from 12-48 hrs. During this time I am completely unable to function. Mine will possibly never heal.
I suggest trying to get a referal to a neurologist. They will be able to diagnose this condition simply by symptoms. It is not a serious (life threatening) condition. However, it is very painful ant there are things that can be done (medications, physical therapy, and proccedures) to ease the pain.