It was originated in 14th century.
It actually meant doing a somersault or cartwheel. As during performing a somersault our head and heels are upside down. So the phrase was used to indicate when things are upside down or very messy.
It is amusing to know how language can communicate the meaning even when it makes no literal sense.The best example is 'Head over heels'.After all, our head is normally over our heels.
But now it is more used when one falls deeply in love.It is also used when someone is very excited and is full of energy about something.
1)When talking regularly with him ,I soon found myself head over heels in love with this guy.
2)My things went head over heels when I went on a holiday trip for a month.
3)He went head over heels when he was announced as the best student of the year.
4)She went head over heels when her parents surprised her with their visit.