Why are compost worms sensitive to light?
It will sounds counter-intuitive you but earthworms do sense light with their skin. They don't have eyes but they have specialized nerve ending equipped with photoreceptor cells. They are all over skin but concentrated towards first segment of worm. Prostomiun are main light sensing organ in worms. Following image shows their position in first segment of earthworm. (Image source: cronodon.com).


Closer look of above image taken from same website,



Structure of photoreceptors

Earthworm have microvillar photoreceptors like insects (Rohlich et al 1970). Detailed structure is discovered long back. 


There is not much information about phototrasnduction in worms but it is well characterized in it's close relative C. elegans (Ward et al 2007).

Now coming to why part, you might wonder if they are spending most of time buried why do they need photoreceptors ? @AMR has guessed it correctly. They use this as protective system. Photoreceptors helps them providing information about how near they are to surface because UV radiation will harm them or probably kill. If there is higher light sensing, they go back to darker regions. You can find similar information from UMICH press release.