Both molecular mass and formula mass signify the same thing that is the total mass of a substance. While molecular mass is used for covalent compounds, the term formula mass is used for ionic compounds.
The molecular mass of a substance is the sum of the atomic masses of all the atoms present in a molecule of that substance. It is expressed in the atomic mass unit(u). Thus, to calculate the molecular mass, the atomic mass of all the atoms present in it are added.
For example, molecular mass of glucose C6H12O6=6(C)+12(H)+6(O)=180u
The formula mass of a substance is defined as the sum of the atomic masses of constituent atoms in an ionic compound. This is generally used for ionic compounds which do not contain discrete molecules, but ions as their constituent units. For example, in sodium chloride, the sodium and chloride ions are arranged in a three-dimensional structure, that is there are two different entities and not a single entity (like in a molecule). Therefore the formula mass of sodium chloride will simply be
= mass of sodium atom + mass of chlorine atom
= (23 + 35.5)u
= 58.5 u