Why does my iPhone flash when I receive a message?
This is a feature introduced with the iOS 5 update.


  Accessibility improvements:
  
  
  Option to light LED flash on incoming calls and alerts for iPhone 4S and iPhone 4
  Custom vibration patterns for incoming calls on iPhone
  New interface for using iOS with mobility-impairment input devices
  Option to speak a selection of text
  Custom element labeling for VoiceOver
  


You can change the setting in Settings -> General -> Accessibility options: