You need to take the two objects and compute a bounding sphere that encapsulates both objects, then you need to find the distance that fits your particular camera to that sphere. Then you just place the camera that far back.
Math here: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene
Cheers,
Nick