Review progress and follow-up. Interruptions are huge time-wasters. At the very least, they break your train of thought. More often than not, you spend precious minutes on something that is not important or urgent. Discourage people from dropping in without an appointment to chat except at appointed times.
People are free to drop in then without an appointment.
When someone comes in your office at another time, politely ask the purpose of the visit. Determine if it is important and urgent and needs your immediate attention. If it does not, set up an appointment to meet with them. Alternatively, establish a door policy. If your door is open, you are available to your staff.