Locking iPhone turns off the display to save your battery and to prevent unintended operation of iPhone. You can still receive calls and text messages, and you can adjust the volume and use the mic button on the iPhone stereo headset when listening to music or on a call.
Choose General > Auto-Lock and choose a time.