Insects do have a nervous system, even if it isn't nearly as complex as that of other animals. Can insects or other arthropods sense pain? Does their aversion to harmful stimuli suggest that they can 'feel' pain in the sense that other animals seem to?
This question has been asked in different forums and many of the answers say that there is no nociception in insects. This book, however claims that Drosophila do have heat induced nociception and is mediated by TRPA ion channels. Also, there is a gene called painless whose mutation causes loss of nociception.