To the question in the title, yes: because if it couldn't, then the DM can't tell you anything
You cast Augury to gain information you don't have. If Augury prevented the DM from using information you don't have, then the DM can only use your own knowledge, and tell you only the things you already know.
Then drinking from the poisoned well, which you don't know is poisoned, will yield Weal because you are thirsty, and not Woe because you will be poisoned.
To the question in the body: yes, it is a valid plan. It's useless though
Using a strict and literal reading of the rules, Augury requires "a specific course of action that you plan to take within the next 30 minutes." The question is, does the following qualify as a "specific course of action"? If it does, it meets the criteria for Augury.
If Bag A contains a Demilich, I will open Bag B, else I will open Bag C
Yes, the above is a course of action. It is of the form "If X, then Y. Else, Z." A course of action is "a procedure adopted to deal with a situation." Then we can break this plan down into:
If X (situation), then Y (procedure). Else (situation), Z (procedure).
An objection to this might be, "oh, but then that's two plans!" to which the answer is: it is a singular plan, with the singular objective of finding the treasure (in the context of this Q), but composed of two procedures, Y and Z, and one evaluation criteria, X.
Note that there are no other restrictions on what the COA might be. By RAW, you are not forbidden from posing a COA that is impossible. Indeed, some COAs can be impossible, such as retreating from an enemy who can outrun you.
You are also not forbidden by RAW from posing COAs that depend on information you don't have, as long as you carry it out in the next 30 minutes. You could ask about leaving the rendezvous point in the middle of a war zone, if the extraction unit does not come and pick you up in the next 10 minutes.
As long as it is a course of action, it qualifies for Augury, with no restrictions imposed by RAW.
But it doesn't tell you anything useful
The specific plan in the question:
If Bag A contains a Demilich, I will open Bag B, else I will open Bag C
Does not tell you anything useful, even if it's valid. If you get Weal, any of the bags could still be the treasure. If you get Woe, any could be the Lich. If you get nothing, any could be empty.
The useful formulation of the plan is:
If A contains a Lich, I will open A and B. Otherwise, I will open C.
I will provide a summarized/abridged of the conversation in this chat, to serve as a background for this question and to provide context.
Q: "If B has the treasure, I will open B and D. Otherwise, I will open E." It sounds like, your decision is based on the information you don't yet have.
A: Yes, Augury can provide you information that you don't yet have. Otherwise, it cannot do anything, if the DM cannot use any of their knowledge that you do not know.
Q: Consider a "plan" like "If A has the treasure, I will open A. If B has the treasure, I will open B and stab myself in the foot. If C has the treasure, I will stab myself in the foot. If D has the treasure I will do nothing." I claim that's not a plan because you have no way of knowing which is true and will stand around stuck
A: A plan can be "An intention or decision about what one is going to do" or "A detailed proposal for doing or achieving something." The "else" clause is a contingent plan.
Q: You can't do: "if there's buried treasure at the beach, I'll go to the beach, else the movie" because you DON'T KNOW if there's treasure until you look.
A: You are asking a god to check for you. You don't know, but Augury directs the question at someone who does -- ie, the DM.
Q: But there's nothing in the Augury spell that says the being that knows the answer tells you. It says it tells you the result of your plan.
A: The god will not tell you the "free" answer though, only Weal, Woe, Weal and Woe, or nothing.
Q: OK, so what do you think augury can do? What bits, if any, do you think it can do that are not in the spell description?
A: All you need is a specific course of action that you plan (but are not bound to take, as of course, receiving Woe should enable you to change your mind), and you may receive an omen.
We then go into defining what is "a plan" or "a course of action," and if "if Bag A contains a demilich, I will open Bag B, else I will open Bag C" qualifies as either a plan or a course of action. However, at this point, the querent decided to ask the question to the Stack instead, so this Q is essentially the continuation of that. As such, I cannot abridge it -- this Q is that continuation.