I think the phrase "what do you do" is too casual. If I am on a formal occasion, what expression can I use to ask the other's role in the office?

Native speaker’s answer
Rebecca
On a formal occasion, you could use the phrase "What's your profession?", "What field do you work in?" or simply, "What's your role in the company?" if you know what company they work in. However, I would say even on formal occasions it's okay to ask "what do you do?". Ex: I'm a writer, I write books. What about you, what's your profession? Ex: I've seen you around before. What's your role in the company? Ex: It's lovely to meet you ... What field do you work in? Ex: Ah, your holiday house sounds amazing, Darren. Tell me, what do you do?