Michael’s inability to keep a secret is the engine of the episode. He views the secret not as a confidence to be kept, but as a "friendship token" that validates his bond with Jim.
Finding out Oscar is actually at home with his partner, Gil, provides a layer of dramatic irony. Dwight assumes Oscar is just being lazy, completely missing the fact that he has uncovered Oscar’s own private life. 💔 The Climax: The Truth Comes Out [S1E12] The Secret
Jim’s desperation to keep Michael happy (and quiet) forces him to participate in a social ritual he clearly finds embarrassing. Michael’s inability to keep a secret is the
Jim’s quick thinking—claiming he had a crush on her "years ago"—is a heartbreaking moment of self-preservation. Dwight assumes Oscar is just being lazy, completely
It forces Jim out of his comfort zone of ironic detachment and into a position of genuine anxiety.