Cloaking Devices challenge the ideals of the United Federation of Planets, and so are not widely used within Starfleet. For certain Federation adversaries, though, it's another story.
The Federation operates as a diplomatic and scientific organization, so cloaking devices have had a low priority in the hierarchies of Starfleet, due to their purely duplicitous function. In addition, the Treaty of Algeron, a peace treaty agreed with the Romulan Star Empire, prevents the Federation from pursuing ship-cloaking technology.
The Federation's first encounter with a cloaked ship comes after 100 years of peace with a Romulan vessel crosses the established Neutral Zone in 2266 to test its new visibility cloaking device. However, when the USS Enterprise NCC 1701, with Captain James T Kirk in charge, encounters the Romulans, Kirk finds the cloaking device effective, but flawed. The cloaking shield's massive power requirements leave only impulse power to propel the ship, decloaking is necessary prior to engaging weapons and transporter systems, and Romulan sensors are virtually blind while cloaked. The Enterprise sensors are able to track the ship - not well enough to establish a weapons lock, but well enough to defeat them.
Not long after, the Romulans, and Klingons briefly join forces and produce an upgraded cloaking device that can't be tracked with sensors and works on warp-capable ships, in response, the Enterprise steals the device for study.
Nothing new By 2293 the Klingons have a prototype version of a cloaking device that allows torpedo fire without decloaking. This Klingon Bird-of-Prey is destroyed by the USS Enterprise NCC 1701a and the USS Excelsior NCC 2000 when it attempts to disrupt the Khitomer peace conference. The innovation obviously fails, as later cloaked vessels cannot fire any weapons.
The Romulans withdraw completely from sight after 2311. When they reappear in 2364 and cross the Neutral Zone, Captain Jean-Luc Picard discovers their cloaking devices have no additional capabilities.
In 2365, Commander William T Riker becomes, via the Officer Exchange Program, the first Starfleet officer to serve on a Klingon ship and see the cloaking device at work. The following year, Romulan Admiral Jarok defects to the Enterprise and shares some cloaking secrets with Chief Engineer Geordie LaForge.
LaForge puts this information to use to detect cloaked Romulan ships secretly aiding a Klingon coup. La Forge's tachyon detection grid with a tachyon pulse, which also coats each of the Romulan ships with a unique tachyon signature which reconfigured photon torpeodes are programmed to seek.
Klingon help A few months later, while investigating the disappearance of Ambassor Spock, Picard is transported to Romulus in a Klingon ship with cloaking protection. He lands undetected.
Even some renegade Ferengi, in 2368, try to capture the Enterprise using an old B'rel class Klingon Bird-of-Prey equipped with a cloaking device. In another incident, Lieutenant Commander Deanna Troi, disguised as a Romulan, receives a first-hand education about cloaking devices when the Enterprise is, again, the target of a cloaked ship. Upon learning that Romulan warp engines will emit detectable particles if even slightly imbalanced, she uses the particles to warn the Enterprise.
Federation Subterfuge A Major scandal involving cloaking technology is revealed in 2369. Despite the Treaty of Algeron, certain Starfleet personnel, 12 years previously, develop a cloaking device along the lines of the Romulan molecular phase inverter. The Starfleet device is tested on the Pegasus, but the crew mutiny against Captain Eric Pressman once they see the cloaking device. Helmsman Will Riker, fresh out of Starfleet Academy, blindly defends and escapes with Pressman - moments before the ship explodes. Romulans discover pieces of the Pegasus 12 years later, and Pressman (now Admiral), aboard the USS Enterprise NCC 1701d, is desperate to find the ship first. Picard finds it - half intact and half fused with an asteroid - and Riker reveals the truth. A number of officers are laster court-martialed over the incident.
Just two years later, the Romulans loan their cloaking device to the Federation under the looming threat from the Founders and the Jem'Hadar. The device with a list of Romulan restrictions about its use, is installed on a new Federation warship, the USS Defiant, captained by Commander Benjamin Sisko out of Deep Space Nine. Though the Jem'Hadar find a way of penetrating the cloak, it is still deemed useful because it makes the Defiant more difficult to detect. As usual, though, the Defiant must declock to fire weapons - a disadvantage cloaking technology is still to overcome.