In computer programming what is the difference between a switch and a transistor?

In the general subject of computer programming neither switch nor transistor exist as concepts. They are out of scope.

The language C (and its relatives) have a switch statement, but still no concept of transistor.

The switch statement of C is a statement in the general class of multiple way decision statements (aka multiple way branch statements) and are called other things in other languages:
  • FORTRAN IV - computed GOTO statement
  • Fortran 95 - case construct
  • BASIC - ON ... GOTO statement
  • COBOL - EVALUATE statement
  • PL/1 - SELECT statement
  • Pascal - case statement
  • Ada - case statement
  • etc.