For whiplash, the typical first treatment is a cervical collar or brace. That will support your spine and head as the soft tissues heal. Read this article to know how long you'll have to wear a brace and how exactly it will help relieve your pain.
You can do a few things to prevent whiplash, even if you can't protect yourself from being rear-ended while in your car. You can, for example, always wear your seat belt. Read other tips for whiplash prevention.
Very few patients with whiplash end up needing cervical spine surgery. If your doctor recommends it, though, there are several options. What kind of surgery you have depends on what parts of your cervical spine have been injured.
Physical therapy is an effective way to deal with the pain and other symptoms of whiplash. A physical therapist will use passive treatments to help your body heal, and you'll probably learn exercises to help strengthen your neck muscles.