A number of people have reported difficulty in calibrating their 3G S Compass.
The documentation is rather vague in the procedure. It states:
"The compass needs to be calibrated the first time you use it, and may need to be calibrated occasionally after that. iPhone alerts you whenever calibration is needed.