You feel ashamed when you have done something wrong or morally / legally / ethically unacceptable.
On the other hand, you feel embarrassed to do something that you may not be socially comfortable with or when you find yourself in an awkward situation.
A politician is supposed to be ashamed of his unruly behaviour in the Parliament;
A policeman is supposed to be ashamed of his corrupt practices.
The student was ashamed of his poor performance in exams.
I was embarrassed when I forgot the Chief Guest's name while welcoming him.
It was embarrassing for the English teacher when the student pointed out her grammatical error in the English class.
He was embarrassed when he had taken his guests out on dinner and forgot to take his wallet.