How to Get iTunes to Recognize an iPhone With a Passcode
The first time you connect a pass-code-protected iPhone to a computer, iTunes asks you to unlock the phone to prove it's really yours. If you want iTunes to stop prompting you, sync the iPhone to your computer. Once you complete the first sync, iTunes stops bugging you about the pass code. If you forgot your pass code without ever having synced your iPhone, the only way to access the phone in iTunes is through a factory restore.
1 Syncing the Device
Syncing your iPhone in iTunes enables you to transfer songs, photos, apps, contacts and other files between your device and your computer. It also creates a backup of your iPhone's settings and data. To set up syncing, connect your iPhone to your computer and click the "iPhone" tab on the iTunes toolbar. Click "Apply" to begin the first sync. The next time you connect to iTunes, your iPhone syncs automatically.
2 Forgot Passcode
If you locked yourself out of your iPhone, and you've never synced the device, you can use iTunes to factory restore the device and remove to passcode. You also lose your settings and data. To restore the phone, first turn it off and then hold down the home button. Connect the phone to your computer with the included iPhone USB cable while still holding the button. Let go of the button when you see the iTunes logo. Click "Restore iPhone" in iTunes to factory reset the device and remove the pass code.
Information is this article is based on iTunes 11 and iOS 7. It may vary with other versions.