When you have to convert a quantity you need to multiply by a fraction whose value is 1 but has different units of measurements.
In your case you have: [tex] \frac{1 g}{cm^{3} } [/tex]
You will have two fractions: one that transforms grams into kilograms and one that transforms cm³ into m³. You need to position the quantities in such a way you can eliminate the original ones, therefore: