I heard someone use the sentence "When will you be leaving?" I want to know why this sentence was used instead of "When will you leave"?
It's more formal and polite, and also somewhat less obligating. It's more formal because it doesn't feel as halting as "When will you leave", and in English, letting things flow over an extra couple syllables can help a lot. It's also more polite, because "When will you leave" sounds like you're interested in them being gone, not in the last chance to see them before they go. And it's less obligating, because leaving is something that can take a while, you can go around and say goodbye to everyone before you step out, maybe you'll get caught up in a conversation or two, and you might stay a while longer even though you should be going... So, you can claim to be leaving up to 30 minutes before you actually plan to step out the door.
That said, it does sound a little too formal for casual events. A more everyday way of saying it is "When are you planning to leave?" That keeps the politeness and light obligation while still sounding friendly.