Could anyone tell whether these 2 phrases are used correctly
To whom do I owe the pleasure?
This is a polite but formal way of enquiring, “to whom am I indebted for this act of kindness? Right?
Like if someone texted you after many years, you could say To whom do I owe the pleasure? Right ?
To what do I owe the the pleasure?
One might say when visited by a friend one hasn’t seen for a long time. Right?
Are both the differences correct?
generally speaking, people don't say this anymore.
Your first example doesn't work because (I assume) you know who texted you.
Your second example doesn't work, because you can see who is visiting you.
It seems to me that you may be learning English from a book that is out of date.