There are two ways to erase it. Once is through iCloud (if you have iCloud enabled on it) and other one is through iTunes on your computer.
On your computer, go to www.icloud.com
Login with your iCloud ID and password. Click Find My iPhone option. Under Device, select your iPhone at top middle. Click Erase button and this will erase the iPhone remotely if it is connected to internet, which will remove the lock.
If that didn't work, then you have to restore your iPhone from iTunes on your computer.
Follow the steps below to restore your iPhone by putting it to recovery mode.
First download and install latest iTunes on your computer from here : https://www.apple.com/itunes/download/
Then connect the iPhone to your computer with the USB Cable.
Open iTunes application on your computer.
On your iPhone press and hold the Home button and the Power button at the same time UNTIL you see a USB cable pointing to iPhone icon on the iPhone's screen. The iTunes will also detect a iPhone in recovery mode and ask you to restore it.
Click Restore or Restore and Update button.
Note : Put it to recovery mode while connected to computer and also in recovery mode your iPhone will show USB cable pointing to iTunes logo. And it will take a while to restore it.
Please let me know if that didn't work, so I will continue to help you until we fix the problem.