I found this info...
The colorful spots are the clam's "eyes" and allow it to sense light intensity. If a shadow falls on the clam, it will quickly withdraw into its shell.
Clams possess a very basic nervous system, consisting only of nerve ganglia (bundles) which control the organs and organ systems, and also receive sensory data from the clams iridiphores (eye like organs). Notice when you pass your hand over a clam creating a shadow, the clams closes up. The iridiphores can only sense the amount of incoming light.
Additionally, many of these worms will have eyes. Typically the eyes are pigment spots on the top of the head, and typically the animals have either one or two pairs of them. These eyespots are incapable of resolving an image, but they are certainly capable of determining the direction of light or a sudden shadow.