I've found on some Russian website a tutorial on how to fix Nokia 5800 earpiece problem.
So, I've tried my best (with Google help of course) to translate it and here is what I've managed to do:
1) Take the plectrum (a three-cornered-stylus, which came in the box).
2) Take the device, turn it off and remove the battery.
3) We start to remove the upper panel (see diagram). Getting started is strictly bottom, so as to stay top of the plume and accelerometer sensor lights.
4) Removed the lid. You should get as in the picture.
5) Now we see the speaker. It should be pulled out and turned.
6) There will be two contacts which should be unbent (see figure).
7) Unbend them and then reassemble.
Everyone can now forget about the problem with the speaker.
Hope the guide was helpful
Russian site source
So, I've tried my best (with Google help of course) to translate it and here is what I've managed to do:
1) Take the plectrum (a three-cornered-stylus, which came in the box).
2) Take the device, turn it off and remove the battery.
3) We start to remove the upper panel (see diagram). Getting started is strictly bottom, so as to stay top of the plume and accelerometer sensor lights.

4) Removed the lid. You should get as in the picture.

5) Now we see the speaker. It should be pulled out and turned.

6) There will be two contacts which should be unbent (see figure).

7) Unbend them and then reassemble.
Everyone can now forget about the problem with the speaker.

Hope the guide was helpful

Russian site source