It is always best to have your track near your programming device (Command Station, SPROG, or Computer).
For greater flexibility, the track should be part of the layout trackage. The reason for this is to minimise the handling of the finely detailed locos on your layout.
To prevent a running loco from accidentally shorting the program track I have wired my section of track as shown below. The programming section needs to be 50% longer than your longest loco and the isolating section needs to be longer than your longest loco.
This is how I connect the 4PDT ( 4 pole, double throw ) switch to the track. When the switch is in the up position both sections of the track are connected to the layout and act as part of the layout. When the switch is down, the program track (BLUE) is connected to the program device and the Isolating section (RED) is totally disconnected and the LED turns on.
The red LED can be a signal near the track or mounted between the track, or on the front of the facia.