What factors determine whether nasal cannula or facial mask is used?

Mostly convenience. Nasal cannulas are less clumsy and obtrusive than masks, and you can eat and drink (and speak clearly) while wearing one. So whenever possible, a cannula is used. In an emergency, or during surgery, or when no cannulas are available, a mask is used.