Switch "Touch Bar shows" per app
You can designate certain apps to show function keys instead of app controls (in the touch bar) by adding them in System Preferences → Keyboard → Shortcuts → Function Keys.

Related: Is it possible to set touch bar in F1-F12 mode for a specific app?