This writing technique is called a parenthetical aside, and it can be used in various genres (including novels, poems, plays, speeches, and films). Parenthetical asides are often a key component in dramatic irony, as they allow the author (or speaker) to share information with the audience that the other characters may not have access to. As you pointed out, these asides often have an ironic or cynical tone and may work to undercut the information previously presented [i.e., I told the dentist that I floss every night (or every three weeks).]
This technique has been employed since the days of oral storytelling, and it is featured prominently in many Shakespeare plays.