As a DM, how does one decide which attack a monster uses during any given turn? Some monsters, such as night hags, have multiple spells and attacks at their disposal and I'm curious if there is a way I should decide which one they use. Is it just left up to the DM to role play the monster in combat or is there some other way of determining what the monster will do?
The same way a player does: based on their priorities.
Most PC's have multiple official ways of attacking (and limitless other creative options) and have to make a decision about which one to use every turn. Being a DM is basically the same, except you might control more than one character.
OK, but how does anyone decide what move to use in combat? Well, it usually depends on personal style and what they're trying to achieve. Here are some of the things I try to take into account when playing or running a combat.
Probably the most common way to play DND (though 5e, relatively speaking, emphasizes other styles more than 3.5 or 4e did) is with an emphasis on tactical decisions. So, you pick whichever option makes you most likely to win the fight. (What counts as a good tactical decision will, of course, depend on the situation.)
Based on established goals and characterization
This is the capital-R Roleplaying approach, aka "think like a monster," though it applies equally to sentient/humanoid NPCs. Maybe these goblins are new at this and aren't going to use the most effective tactics - maybe they'll charge in one at a time and leave themselves open, or (probably more likely with goblins) run away as soon as a threat appears. Maybe this particular knight always challenges his opponents to hand-to-hand combat, even though he can also use spells. Maybe the spider's goal is to grab one meal if they can, but run away regardless. If you're playing the sort of game where PC's have these kinds of limitations and motivations, the DM should decide on them for NPCs as well, so it's not a world full of jarringly well-coordinated and bloodthirsty monsters.
Based on what would be good for the story
If you want the PC's to be ambushed with a spell that does a lot of damage, use that. If you're trying to get the PC's captured rather than killed, use less-lethal moves (also ties into the previous point.) If you think "Oh man, wouldn't it be AWESOME if..." then do that (or preferably, let it be the result of something the PC's did!) Side note: One common aspect of this way of thinking is trying not to get the PC's killed, at least not most of the time. For example, if you want your players to meet an overwhelmingly powerful opponent but not fight to the death yet, come up with some excuse to let them off the hook - maybe the NPC gets annoyed and wanders off, or is saving their ultra-mega-move for worthier foes.
Basically, it really is totally up to the DM - but these are some of the patterns that emerge. As you can probably tell, there's a lot of overlap; you're unlikely to pick one of these and ignore the others for a whole game, and even if your personal style usually focuses on one of them, there may be times when it's good to branch out.
Unless the monster's entry states that they have a preferred way of attacking it is up to the GM to decide. When playing intelligent monsters the GM can choose the spell or attack that seems most efficient in that situation. Or he could choose a rather harmless one if the party seems to be losing.
If the fight is going bad the monster might use spells or attacks that help it get away, like shocking grasp, that prevents the use of a reaction by the target.
Sometimes you don't want to bring your own biaseness into the battle. As DM, you know the weaknesses of the PC's and may not want to use your insider knowledge to always target using the ideal attacks. This is not something you use all the time, but when chance is called for:
Count up the different types of attacks, pick a corresponding dice; select another dice depending on how many PCs. Roll and check results.
This makes the encounter random and without bias.
I generally start with a weaker attack and switch to stronger ones mid battle to shake things up and keep players guessing.