Hi. My son just had exactly the same problem from when he first started to use the handsfree / headphones socket.
It seems that there was a fault in the socket. The phone believed that the jack was in the socket even when it was not, so it disconnected the phone's speaker and microphone. We kind of got a clue as the handsfree jack did not give a very convincing 'click' when it was put in or out.
The solution was - he prayed hard and then repeatedly pulled the jack plug in and out rapidly until it the socket began to 'click' properly. He then took the jack out and it has been working fine ever since.
Hope this helps. Chris
This is exactly what has happened to mine, does yours still work with the earphone in? It was suggested that I need to flash the rom as my problem occured after I had been making some space in the windows folder. Big mistake, anyway its either a broken speaker, plug or the rom. if you find another solution let me know.
Usually answered in minutes!