How can they tell? They use the information gleaned from both the history and physical exam. They take into consideration your age, general health, and risk factors for significant disease.
The major causes of serious conditions leading to neck pain include infection, tumor, and fracture. Anyone suspected of these three things would automatically have further imaging testing done.
Other risk factors for neck pain that doesn't go away include the use of tobacco products (or exposure to second-hand smoke), poor health, and psychologic distress. A history of car accident or other trauma leading to whiplash and whiplash-associated disorder (WAD) is another risk factor for chronic neck pain.
Hopefully, the history would have brought out the possibility of car accident, domestic violence, or other trauma suggesting the need for further imaging or testing.
Hospital emergency staff are trained to warn patients what red flags to look for. These warning signs suggest the need for a return visit to the emergency department or a follow-up visit with their regular doctor.
If you develop visual changes, dizziness, numbness of the face or down the arm, or slurred speech, don't wait. Get to a doctor or medical facility right away. These are symptoms of an impending stroke. Immediate attention is needed.