The portion of the spine in the neck (called cervical) is similar in many ways to the low back (lumbar) in that it is composed of bones (7 vertebrae) united in front by discs and behind by synovial joints, and traversed by elements of the neurological system. Where it is different is in the mobility of the neck, and the nerve element is the spinal cord which fills most of the space and is much less tolerant of an intruding piece of disc.
Surgery is likely indicated in any condition that results in compression or jeopardy to the spinal cord. This may be caused by trauma, which has fractured the vertebrae, or dislocated them; or it may result from disease such as tuberculosis with an abscess, or rheumatoid arthritis which has loosened the joints, and compression of the cord, paralysis or death may follow an incautious movement.
Surgery is sometimes indicated but often not essential for nerve root compression. At every level of the spine a nerve root is given at each side, which unites with other roots in a complicated but reasonably predictable manner to form nerves. If your neck has been a bit stiff (a crick in the neck) for a few days and you wake in the morning to find that your thumb is numb, there is probably a disc protrusion (herniation) compressing the nerve root that goes to the thumb.
Surgery for chronic pain is much more difficult decision. Here, there is plenty of time to try alternative measures such as rest, medication, and physiotherapy. To determine the cause of the pain is often difficult as the “obvious” disc or joint problem seen on the X-ray is may not be the cause of pain, and operating on it may not relieve the neck pain.