How to turn off your iPhone if your On/Off button doesn't workIf your iPhone's On/Off button stops working, you can use AssistiveTouch to control your device. Here's how!
Updated February 2017: New information on how to power down your iPhone with Assistive Touch.
Powering down your iPhone is pretty simple: You hold down the On/Off button and slide to power off. But what do you do if your On/Off button stops working? Your first step is to check if you're still under warranty! If you're still covered, you can get that On/Off button replaced — likely free of charge — at an Apple Store. Apple has a special support page that'll let you check your device's coverage.
Check Your Service and Support Coverage
If your warranty has expired or you just need to get the darn thing powered down, you can use AssistiveTouch to get on-screen controls that'll let you power down your device.
How to activate AssistiveTouch and power down your iPhone
Launch Settings.
Tap General.
Tap Accessibility.
Tap AssistiveTouch under the Interaction category...
Source:
How to turn off your iPhone if your On/Off button doesn't work