Players are always going to do stuff that is unexpected. The question is does what they are doing make sense in the context of what is supposed to be happening. If not seek clarification, because it is often the case when the players actions do not seem to make sense that there is a misunderstanding between you and them.
If you are running a published adventure and they are going off the published path. Remind them, out of any character that you are new to this, that they agreed to play a published adventure and would they kindly get back on the cho cho train or if they want to continue with this path, what is their goal and you will have something ready next week.
You can do the same thing if you are creating your own materials and they have wandered outside the scope of what you have prepared.
Tell them you will endeavour to do better in the future.
Random table can help as can some precanned encounters that you can plop down to pass the time and cover the fact that you were not ready for this. A couple linked encounters that have no given location or real plot function, It does not have to be a combat encounter. They can meet Farmer Maggot and be invited to tea and he has some gossip that leads them back to the place you want them to be.
I would highly recommend "The Lazy Dungeon Master" and "The Return of the Lazy Dungeon Master" by Mike Shea (aka Sly Flourish)
One More thing that I have noticed newbie DMs do is impart information that should be imperatives from local authority figures as something more vague where the party feel that they should be more proactive.
For instance I am playing in the new Dragonlance adventure where the start is a very hard railroad.
The DM gave us the impression that we had to choose a course of action regarding the ambush we encountered on the road to the starting town. When he should have said "Look there are no professional troops available and everyone is out at the funeral, preparing for the festival or keeping order in the town. Why don't you lot attend the reenactment tomorrow and get to know the local militiamen, we can meet up the day after and discuss options."
Don't bury the lead, do not give options if there are none and do not spend too much time describing the furniture if the furniture is not important but the painting over the fireplace is.
The player will pick up on what you appear to give emphasis to and this might lead in directions that you did not intend. With experience you will be able to roll with it.