What is the right situation for doing a nutmeg? When the defender stands on both feet, when one foot is closer to you than another? Or maybe it can be performed in any situation? I just want to know: is there any template situation when it is more likely for doing nutmeg?
Well, this is pretty objective, but the right time for a nutmeg is when it's the easiest move to pull off considering the inherent risk involved with it (i.e. kicking the ball straight towards the defender). Ideally, the defender would be perfectly square to you with their feet spread wide and set back on their heels, perhaps right after you've done a nice hesitation move.
This would give you the best chance to thread the ball through their legs without just bashing it into their shins while they're on the run and potentially losing possession. Additionally, you don't want them to have time to react and block the ball, so it's best to preface the nutmeg with a stutter or fake pass that will make them hesitate. Mind you, a good defender will make it tough for you to ever have a good opportunity to ever pull it off - they'll be trying to move you towards the sideline or other defenders and will rarely square up.
I don't have a legit source for this other than playing for over a decade and plenty of trial and error trying to make my friends look like fools. And maybe being made the fool once or twice. But if you watch videos of it done successfully, you'll find the above generally holds true.