‘Om Namah Shivaya’ and ‘Om Shivaya Namah’ are mantras dedicated to Mahadeva, Lord Shiva. Although it appears and considered that there’s not much difference in ‘Om Namah Shivaya’ and ‘Om Shivay Namah’, there’s a slight difference in their meanings.
Normally, ‘Namah’ is used after the God’s name, especially when want to refer them directly. For reference, we refer to Lord Rama as Om Ramaya Namah.
Some people believe that meanings of both the mantras are same, “Salutation to Shiva”. They thought that to impress the Gods, it’s more appealing to sing it than simply calling the names. So basically, “Om Shivaya Namah” is just direct saying, and “Om Namah Shivaya” is its poetic version. As per Vedas, you can notice there’s a unique rhythm for each mantra.
However, as per others, the true meanings behind the Om Shivaya Namah and Om Namah Shivaya mantras are:
Om Namah Shivaya – Sthula Panchakshara
The mantra Om Namah Shivaya is chanted to gain worldly objectives (Om Namah Shivaya – Meaning and its Significance)
Om Shivaya Namah – Sookshma Panchakshara
The mantra Om Shivaya Namah is chanted to attain Moksha – Liberation
Saint Vallalar wrote that when one applied sacred ash on the forehead, one should say ‘Shivay Namah,’ because it confers on a devotee good speech, good company, good qualities, and moksha.
Sambandan explains the difference between ‘Om Namah Shivay’ and ‘Om Shivay Namah’ in an article published in The Hindu.
Each of the letters in these mantras has significance. ‘Na’ represents our pride, ‘Ma’ represents the impurities in our minds, ‘Si’ represents Lord Siva, ‘Va’ represents Goddess Sakti, and ‘Ya’ represents the Atma. So when we say, ‘Sivaya Namaha,’ the Atma, represented by ‘ya,’ is in the middle. On one side are the pride and other impure thoughts represented respectively by ‘Na,’ and ‘Ma.’ On the other side of ‘ya,’ we have Lord Siva and Goddess Sakti represented by ‘Si’ and ‘Va.’ So it is for us to decide what we are going to do. Will we go the way in which temptation leads us? Or will we turn towards God? The ‘ya’ comes right next to ‘Va,’ for the Goddess is even more merciful than Lord Siva. After all, an erring child is afraid to approach its father. It first seeks forgiveness from its mother, who recommends to the father that he must not judge his child harshly. In the same way, the Goddess makes sure that the Lord’s wrath is not directed towards us. She speaks to Him on our behalf. To get His mercy, we must go to Her first. His mercy then automatically comes to us.