Most worms are harmless and are beneficial to the tank as they eat all the detritus in your sand bed. If it has spines, then it is most likely a bristle worm.
Some varieties of bristle worms can eat your corals, so if you see your corals being damaged, check them out with a flashlight at night to see if it?s the worm that?s doing the damage. The greater majority of bristle worms are harmless to your tank, however they can sting you, so be careful when moving rocks and corals around.
They sell 'bristle worm traps' (I?ve seen them at petCo) which is basically a long plastic tube with a tapered hole on the end, that you put some bait in. The worm goes down the hole and cant figure his way back out. Others have made traps using any kind of small container with holes and bait. I?ve heard of people using a leg stocking with bait in it.
There are also fish that will eat bristle worms. However, the same fish usually will eat other similar critters in your tank such as other good worms, feather dusters, and copepods. One good fish for eating bristle worms is the six line wrasse.
Check out Ron Shimek's links here:
http://www.rshimek.com/reef/OnlineArticles.htm
Scroll down to the sections on "Annelida" and "Polychaeta (Bristle Worms)". The links there should help you identify your worm and decide what to do about it.