You have to calculate the distance that the camera’s focal plane would need to be from the camera to include the target object. If the object is not on the camera’s z axis, it involves a little vector math, but that is greatly simplified by AE’s dot product operator.
For a target layer named “target” the expression for Focus Distance would look like this:
P = thisComp.layer(“target”).position;
dot(P – position,toWorldVec([0,0,1]))
For serious depth of field effects you’re probably going to want to crank the Aperture way up (in the hunderds).
Dan