My iPhone 3G becomes unresponsive

Hello! An irritating problem I have. The touch screen on my iPhone 3G becomes unresponsive sometimes. The home button works so the phone isn’t stuck but touch doesn’t work at all. The touch works perfectly again if I lock the phone and unlock it.
I have no idea why this happens sporadically. It always works after a lock/unlock so I am thinking it’s a software error.
I request ideas from anyone.
