Rolling a Perception Check
When you're trying to see through a deception or search for something hidden, you must declare that you're trying to look for clues, and describe what and where you're searching. This entitles you to a Perception check, which is a Deft check using the Perception skill (or any other skill that makes sense for the situation).
Detecting Stealthed Opponents
Searching the Room
First of all: if you happen to search the part of the room where the secret thing is, no Perception check is required, you find the thing. But if you're not sure where exactly to search, the GM will provide clues to the hidden object's whereabouts with a successful Perception check.
If you fail, you can only try again if you declare a more specific place to search, or if another character suggests a more specific search. Typically, the GM uses a success check to determine the specificity of the clues or the information gained by the check.
The Surprise Round
If you are stealthed and you attack unsuspecting victims, you get a free round of attacks against them when you reveal yourself to attack. If you are surprised by stealthed opponents, they get a free round of attacks against you. In either case, you get advantage on the actions you take in the surprise round. The surprising party is then revealed and loses their stealthed status.
Only if you have reason to suspect a surprise (you're standing guard, you're suspicious of hidden enemies, etc) can you make a Perception check vs. the surprising party's stealth score to retain your initiative in the surprise round.
Swift Weapons & Detection
When you attack with a Swift weapon, your attack is not considered risky, which means you do not roll to see if your stealth score is compromised.
However, the laws of the fiction still apply: enemies who get stabbed in the back will immediately be on the alert for you, and can no longer be surprised. They may also be entitled to roll a Perception check with advantage to ascertain your location, or learn your general location by spending a turn to search for you. One way to think of the effect of using Swift weapons repeatedly against the same opponents is that each attack against them strengthens their awareness, and eventually the GM is entitled to outright reveal you if you abuse the mechanic in a way that violates the credulity of the fiction.