When the audience knows something a character does not. Every line the character speaks takes on a second meaning, and the tension comes from waiting for them to find out.
In his interviews with François Truffaut, Alfred Hitchcock described a bomb under a table. If it goes off without warning, the audience gets fifteen seconds of surprise. If they see it first and watch the clock while the characters talk about nothing, they get fifteen minutes of suspense. The scene is the same; what the audience knows changes every line of it.
To build it, show the audience the danger or the secret in a scene the character is not in, then put the character in a scene where it matters. Keep the character's behavior believable from what they know. The irony collapses if they act strangely only because the writer needs the tension.
Dramatic irony costs surprise. You cannot both tell the audience and shock them with the same fact, so decide which a scene needs. A reveal leaked early should pay off as suspense; a twist should stay hidden from everyone.
Dramatic irony is about knowledge: the audience knows what a character does not. Situational irony is about outcome: something turns out the opposite of what was expected, for the characters and the audience alike.
It is one of suspense's strongest sources. Suspense comes from waiting for an outcome you fear; dramatic irony supplies the reason to fear it by telling the audience what the character does not know.
Give the audience the information in action they can see: the bomb under the table, the letter in the wrong pocket, the stranger in the back seat. Then write the next scene from the character's ignorance, and let the audience do the worrying.