How to know that I may or may not use interrupt?

When I make pin 12 as the OUTPUT, it is not really stable to hold the switch in HIGH voltage (5V),
so I think it might be due to waiting for another code executed, so I think I should use interrupt to fix it.

An interrupt is like a ringing telephone. It signals that a need for action exists. That has nothing, NOT A THING, to do with your problem.

Using Firmata on the Arduino means that you have given complete control over what the Arduino does to another application. There is no way that interrupts are compatible with that concept.

If setting pin 12 as an OUTPUT, and setting it HIGH does not produce a stable 5V, then you have a code problem or you have damaged the Arduino.

What is connected to pin 12 that is not seeing a consistent 5V? What is the GUI doing to that pin?