There are both political and religious reasons behind the conflicts between the two empires.
Since the establishment of the Safavid dynasty in Persia (Iran) there were struggles between the two empires due to the following:
1. Trade Embargoes:
The Ottomans were consistently using trade embargoes against the Safavid Empire and were arresting the people crossing into their country which culminated into the Battle of Chaldiran (1514) followed by a century of border confrontation.
2. Border confrontation:
The Treaty of Zuhab, signed between the two empires recognised Iraq in Ottoman control, and partitioned Caucasus into two between the two empires.
One of the important reasons of the combative relationship is due to religion. While the Safavid's were the worshippers of Shia Islam, the Ottoman's were the followers of Sunni Islam.
After the signing of a peace treaty, Treaty of Erzurum (1847), peace was ensured between the two empires after centuries of rivalry.