It's used to express exasperated sarcasm. For example, if you accidently broke your mother's plate, they might say (in exasperation) "What am I going to do with you?"
Or if you disappointed your boss, they might also use this expression.
It literally means that the person is at a loss for how to deal with this situation that you created.
I hope this helps! :-)