We can, without loss of generality, take the cost of the cylinder to be 1 times its area and so the cost of two hemispheres is twice their area:
We want to minimize subject to the constraint that .
At this point I don't know how to help you further since there are several ways to do that and I don't know which would be appropriate for you. I would consider "Lagrange multipliers" to be best. Do you know that method.
By the way, the volume can't be "1000 mg". mg is a measure of mass, not volume. Did you mean 1000 ml or 1000 cc?