What is this infrared light on my iPhone 4 and how do I turn it off?
Well, that is the proximity sensor which should detect when you hold the phone to your ear and turn off the touch screen, etc. On my iPhone 5 it is only active when I make a phone call or use a App that uses it (e.g. SmartSleep). It is also visible to the eye when you are in a dark room.

These (rather old) articles (1, 2) has more info and states that this is a known problem on the iPhone 4. They suggests to try the following:


Hard reboot (hold power and home button until the Apple logo appears again)
Reset your settings (Settings > General > Reset > All Settings)
Reset Network setting (Settings > General > Reset > Reset Network Settings)


After resetting you should also reboot the device.