This tutorial is addressed only to those who do not need to unlock their iPhone and use an unlocked phone. Read more after the jump.
Tutorial necessary if you take your Device in Service!
Connect your iDevice to your computer through USB data cable, open iTunes, select your device from the upper left;
Click "Restore iPhone";
If you have enabled Find My iPhone, then you have to disable them to continue. To do this, go to the application Settings> iCloud> Find My iPhone.
iTunes will ask you if you want to backup first.
Please note! If you had jailbreak, iTunes will save files only "legal", that were not installed using jailbreak community. If you want to keep your files, contacts, photos etc, press the "Back Up";
Click on "Restore";
IOS version will download required, then the restore process begins. Follow resetting the phone;
Note that when you install or reinstall restore the latest version of iOS launched by Apple and available on iTunes.
After the phone is activated, it will bring the option to restore using your back up previously did. Choose file backup saved, then click "Continue".
What I recommend, however, is to choose "Set up a new iPhone" to have a restore "clean" and get rid of any traces of the previous operating system.
If you had jailbreak before, after you restore using this tutorial, nobody will be able to realize if you have jailbreak or not, even if you choose to restore the backup.
The phone will restart and then you can start to use them, "the factory".