In "Disaster", Worf is put in charge of ten-forward by Commander Riker. However, there are higher ranking officers on board (for instance a department head like Dr. Crusher). If one of those officers were to come in, could Worf give them orders? Could that officer supercede Riker and take charge from Worf?
There are effectively two distinct questions here.
Can Worf order higher-ranked officers around?
Worf has been given a direct order by the ship's First Officer; to remain in place and support injured crew coming into the ship's refuge area.
RIKER: Okay, you and I will try to get there. Mister Worf, this room is going to fill with wounded in a few minutes and they're going to need help. I want you to stay in charge here.
WORF: Yes, sir.
He isn't 'in command' of Ten Forward, but as fourth-in-command of the ship, he already effectively outranks anyone who isn't Data, Riker or Picard and can give them orders that don't conflict with orders they already have from Data, Riker and Picard.
Can a higher-ranked officer order Worf around?
An officer holding a higher rank than Worf can order him to do things that don't conflict with his existing orders from Riker, but only a very specific set of circumstances would allow them to supersede an order from the First Officer entirely;
Receiving a further order from the Captain or First Officer (or Data, since he's higher in command).
Someone relaying orders from the Captain or First Officer.
Various standing orders and directives from Starfleet.
Orders from the CMO relating to health matters.
Of course, if Worf's existing orders no longer make sense (for example, if there's a second emergency that requires his assistance or he learns that the current emergency is over) he can be expected to use his own best judgement to act independently, and to then to report to Riker, Data or Picard as soon as convenient.
There was a similar situation in the episode The Arsenal Of Freedom.
This was a first season episode. In the first season Geordi was usually on the Bridge, and there was a series of temporary Chief Engineers.
Picard beams down to a planet leaving Geordi in command.
The ship comes under attack. The current Chief Engineer comes to the bridge to take command. Geordi refuses.
Note that the Chief Engineer not only outranks Geordi, he is Geordi's department head, and directly above him in the chain of command.
So there is direct evidence in Star Trek continuity that Worf could have given orders to someone with a higher rank.
Ship's log, supplemental. Lieutenant La Forge in command. I am unable to beam up the away team due to an unseen assailant attacking the ship. To make matters worse, Chief Engineer Logan is on his way to the Bridge, and he's not paying a courtesy call.
LOGAN: Why are we still in orbit? We're taking a beating.
LAFORGE: We've got to hold out as long as we can. Now, if we can disable our attacker, if only for a few seconds, we can drop our shields and beam the away team back aboard.
LOGAN: If we follow that plan, we'll lose the Enterprise. In view of the present crisis, I believe you should relinquish command to me.
LOGAN: I outrank you.
LAFORGE: Mister Logan, I'm in command.
LOGAN: The Captain did not anticipate the Enterprise would come under attack. If he had, would he have left the Bridge to you?
LOGAN: You can't fight this thing and win. We've got to break orbit now.
LOGAN: Lieutenant La Forge. Geordi. I know you want to do what's best for the Enterprise. So do I. Now the best thing
LAFORGE: The best thing, Mister Logan, is for this discussion to end and for you to return to your duties. Now, I'm in charge until relieved by Commander Riker or Captain Picard.
LOGAN: You're ignoring my greater rank and experience.
LAFORGE: Not at all. In fact, just to opposite. I'm counting on it. Now I need you to get back down to Engineering and get me every available scrap of emergency power you can. The more power we can channel to the shields, the longer we'll be able to hold out. Now, Mister Logan.
In the real world, you have what Star Trek often alludes to: the conn
Within the U.S. Coast Guard, Shipyard and U.S. Navy, the captain of a vessel typically selects a junior officer to perform the role of conning for him or her. Such an individual has the title of "officer of the deck" (abbreviated OOD) or "the conning officer" while on duty, and he or she will stand watches at four-hour intervals carrying out the captain's commands. However, the captain can immediately take the conn by simply issuing an order to the helm.
Turning over the conn is a line used throughout Star Trek.
The idea is that the ship's senior officer can leave a junior officer in command. At that point, the junior officer is acting with the authority of the senior officer. In other words, at some point, it's assumed a senior officer will return and assume command. You wouldn't want the captain coming up to you and asking why you didn't listen to the person who was left in command in their stead.
Rank only matters when there is no clear person in charge. In the same episode Disaster, the officer on duty is killed (transcript). The person left in charge of the conn was a Lieutenant. What's interesting is that there was someone more senior than her on the bridge
RO: We need to start emergency procedures. Who's the duty officer?
O'BRIEN: Lieutenant Monroe was in command, but she's dead. I believe Counsellor Troi is the senior officer on the deck.
RO: Counsellor Troi?
O'BRIEN: She carries the rank of Lieutenant Commander.
Could Troi have given Monroe orders if Monroe were in any other capacity? Certainly. A Lieutenant Commander outranks a mere Lieutenant. But Monroe was in command of the bridge at the time. In fact, we never see Troi's rank factor into TNG prior to this.