The camera may have been confused as to where to should focus. Typically cameras default to a focus method that averages the focal length between several points in the view. If you can change this to a "point" focus, or some such other name that the camera maker may use, it will only determine focus from a small area in the very center of the image. Perfect for small subjects like this where just a couple of millimeters can throw the focus off.
If your camera still has trouble focusing after this, you can always take one picture with a multicolored card (something like a magazine pic would do fine) set at the center axis of your intended subject. Once the camera focuses on this, lock the focus at that range and then remove the card and photograph your subject. Make sure you have the focal depth set right as well. If you're not sure where to start, set your F-Stop as close to 6 as you can as a base point, then adjust higher for greater focal depth and lower for less focal depth. Of course, you'll need for light for a proper exposure at higher F-stops, so you'll have to ramp up the lighting a bit, or adjust the exposure values in your camera.
This is assuming your camera can do all this though. And maybe you already know all this, and I'm just rambling.