Sadly you'll have to either take it to apple or open it yourself and check the connections on the main board.
It's either dirty and/or misaligned. Take your back cover off and remove the 2 screws (1short, 1 long) at the top right holding the vibrate motor. clean it with compressed air (very lightly) and isopropyl alcohol on a q-tip, don't forget the contacts on the iphone too. Extend the contacts on the motor a little to ensure proper seating for power. When putting it back make sure it's aligned properly and it doesn't touch anything on the sides. Those motors just don't die considering they are extremely low power motors. Knocking the back of the phone to fix it means it's loose and not aligned until you knock it loose again.