“What did you just say to me?”
You're yelling at your daughter to clean her room. She says, under her breath, "I hate you!". Now you're extremely angry, and you can't believe she said that. You say this.
What did you just say to me?
One of the uses of "just" is to express that something happened very recently. It can mean a few minutes before:
I'm sorry, he just walked out to go get lunch.
Or immediately before:
What did he just say?
Or it can mean a few years:
Mankind has just started to study ways to understand and control DNA.
But in any case, "just" means a short time before.
If you didn't hear what someone said, you can ask:
What was that?
What did you say?
But asking "What did you say to me?" has a completely different meaning. You say this when someone insults you, challenges you, or says something rude:
A: Shut up.
B: Excuse me? What did you just say to me?
You should say this in an angry tone of voice, and stress the word "what".