I'm sorry to say, but you cannot calculate the offset when the axis is measuring nothing or "0g".
Why? Surely if the phone is lying flat the g readings from the sensor should be (x, y, z) 0,0,1 so if they're 0.02,0.043,0.97 then the software knows it has to apply a -0.02,-0.043,+0.03 correction to all the data from then on? Isn't this what it does on a per-app basis when you tap the screen in the Level app to set it to zero?