Is there difference between "by then" and "until then" in the following sentence?
"I'll call you around 9 o'clock. By then (or "until then"), sweet dreams!"
The difference between "by then" and "until then" is that of continuity.
"Until then" means that the thing will continuosly be done till "then" comes.
You go and rob the bank, I'll play the guitar until then.
I will not eat until then.
In both the examples, the action of "playing the guitar" and "not eating" continues to occur till "then".
"By then" means that the action will not be a continuous action. It will be an action for a specific moment and it can be done at any time from now to "until then".
- The party is at 10 P.M., I will get drunk by then
In the above example, the action of "getting drunk" can occur anytime from now until 10 P.M.
Coming to your example , "until then" is the correct alternative.
In your sentence, "until then" is correct, but "by then" is not.
A good paraphrase for "by then" is "before then", not "until then".
Here are a few examples to show how these two phrases are used:
I'll call you around 9 o'clock. Until then, sweet dreams!
I'll call you around 9 o'clock. If you haven't heard from me by then, don't worry.
I'll call you around 9 o'clock. By then, I should have all the details worked out.
Note: you can say 9 o'clock, or 9:00, but you should avoid combining the two forms