When specifying temperature as boundary condition directly or defining external temperature for convection/radiation, you can enter a function instead of fixed value. It can be a name of a function created before in Definitions --> Functions (several types available) or expression written using Matlab syntax. Just be careful with units and with names of variables used by COMSOL. For example if you create a step function named step1, you should enter step1(t[1/s]) in the expression field where temperature is specified. COMSOL will warn you about unexpected units, unknown variables and incorrect syntax, if they occur in your expression.