The Z height must be set to the distance (in the Z direction) from the offset frame to the top surface of the part where the taught vision pattern is. The Z height setting is critical to the accuracy of your vision process.
To determine the Z height either directly measure it or you can use a pointer on the robot with an accurate TCP to find it. If you use the pointer method, then simply set the robot UF to the offset frame and UT to the Pointer TCP then jog the pointer to the surface of your part and write down the Z value.
A good indication that the Z height is wrong is if you move the part (without rotating it) and the robot position does not go to the same position relative to the part.