Here's how you do it. (I did this on a 3G, but from the pictures, it looks identical to 3GS, and the ear piece is the identical part) Follow the guide to get the screen off from the rest of the phone. On the back of the screen part, at the top, there is a black metal piece over the area you would imagine the ear piece is. There is one screw in the top right corner of it. Take that out. This is the hard part - to do, and to describe. The metal piece has 3 clips that hold it to the plastic LCD backing. If you examine it, you will see them - this part is basically flat and ends at the edges, but you will see 3 areas that bend down at 90 degree angles. The clips just have another short part at the bottom that bend in 90 degrees, and it digs into the plastic. One is above and one is below where you would imagine the ear piece would be, and the third one is on the upper portion, also Just pry, and they come out. I made sure that my LCD was face down and I had some pressure against it, that way it didn't bend while ...
The connector/ribbon cable #3 controls the ear piece and proximity sensor.
The ear piece won't output sound but you should get sounds from the speaker on the bottom of the phone.
The proximity sensor senses when the phone is next to your head and it dims the screen to save battery life. (you can test this by making a call and holding your hand over the earpiece area, see if the screen dims)
If you're having both of these issues, the connector or cable is bad. You can use the phone, but it has to be via earphones with a mic, bluetooth headset, or by speakerphone.
You can find the parts on eBay - search iPhone FPC connector and iPhone light and proximity sensor flex cable - about $10 each. The FPC connector needs de-soldered from the logic board and the new one needs micro-soldered back on, so you may want to seek a professional's help if you decide to go that route. Good luck
2 by the dock connector on the outside
8 in the logic board
2 for the vibrator
2 for the lock button
4 for the volume/vibrate buttons
4 for the headphone jack assembly
1 for the SIM card ejector
3 for the dock connector assembly
6 (I think) in the screen assembly =32 Be careful, they're different lengths, some aren't threaded all the way to the head, etc. Should have kept track of where each went, but good luck.