you're looking for the Treaty of Algeron...
The treaty reinforced and redefined the Romulan Neutral Zone, and made clear that any violations of the Zone without adequate notification, by either side, would be considered an act of war. The treaty also expressly prohibited the development or use of cloaking device technology by the Federation. Then-Captain Pressman attempted to circumvent this clause in 2358 with the test of a phasing cloaking device developed covertly at least in some part by Starfleet Intelligence aboard the USS Pegasus.
As far as i know, there's never been an actual reason why the Romulans demanded The Federation not to use cloaking technology... it's just part of Trek history that's never been explained
So the Federation signed a treaty that applied different rules to the Federation than the Romulan or Klingon Empires. This is kind of like the United States agreeing not to use submarines while allowing the Soviets to continue using them during the Cold War. I can't imagine the Federation Representative being well thought of for signing this treaty. Can you imagine how many Starfleet personnel could have lost their lives when their ship came under attack by a cloaked Klingon or Romulan vessel, and those that survived cursing under their breath the signers of that treaty that put them at this disadvantage to begin with?
In point of fact, there are real-life examples of situations akin to the Treaty of Algeron.
Look at the USAF's B-1 Bomber. The aircraft was designed for a payload of 24 nuclear tipped cruise missiles. So configured, if the balloon went up during the Cold War the Russians would be screwed like a Mexican hooker considering just ONE AIRCRAFT had the ability to hit 24 targets with nuclear ordinance-and we initially built 100 of them for service during the late 80's.
This troubling fact was not lost on the old Soviet Union, and as such one of the treaty concessions of the last START talks was permanently modifying the B-1 Lancer's frame to deny installation and use of those nuclear cruise missiles. They haven't been flown on a B-1 aircraft in over 20 years , and yet to this day Russian inspectors hop on a jet and fly over to US bases for a treaty-mandated inspection to ensure the blocking partitions are still in place.
Awesome capability though it was , the U.S. Military has somehow found a way to survive without it.
In looking at the TOA, we must remember that a cloaking device isn't a perfect weapon. Its just another technical tool , subject to tactical limitations and drawbacks. As Kirk's engagements in STIII prove, just because you have a cloak doesn't mean the other guy can't hit you first.
To wit, we also have to wonder what use a cloaking device would serve for a Starfleet dedicated to exploration and scientific research. The primary purposes of the Romulan and Klingon imperial fleets is military defense and conquest, and their equipment reflects this mission.
The primary purpose of Starfleet ships is NOT military operations, although in the event of emergency action this is a role that can be adopted. Not every Captain in the fleet ends up solving exotic problems Kirk and Picard regularly deal with, so for 99% of the benign Starfleet a cloaking device has about as much daily relevance as a fallout shelter.