Grams are mass and milliliters are volume. 1 ml of something very dense will weigh much more than 1 gram. You need to multiply by density to make the conversion and the units will tell you that. To go from length$^3$ to mass you need to multiply by something that has units $\frac {\text{mass}}{\text{length}^3}$ and the density is that.
Avoirdupois ounces are a unit of mass as are grams, so you can just use the conversion factor you quote. Fluid ounces are a unit of volume, about $29.57$ ml. There are also Troy ounces, used for things like gold, that are units of mass but different from the avoirdupois ounce.