Pop off the back cover and make sure there's not a sticker or anything over the speaker or mic.
You could try Voodoo Sound. It's a custom kernel for SGS devices but if you don't want to mess around with that you could just try the Voodoo Control app, it can do some improvements without the kernel. (If you do use the kernel you really need the app as well.)
Otherwise, I would assume it's a hardware problem and you should get a replacement.