BertForPreTraining has two heads, one for masked language modeling and one for next sentence prediction task.  This class should be used when you want to pre-train the bert as described in the paper i.e MLM + NSP
BERTForMaskedLM, is for MLM training which can be used for pre-training.