Many modern engineering systems can be mathematically modeled as hybrid systems. For many such systems, there may be uncertain parameters and also parameters that can be adjusted so that the system achieves some optimal performance. It is important to develop efficient numerical tools and software to optimize for these adjustable parameters. We focus on a specific class of hybrid systems where mode transitions are dependent only on the amount of time spent in a mode (or equivalently a clock value). The amount of time spent in each mode is assumed to be a random variable with a known distribution. We aim to design or choose values for the free parameters in each mode of the hybrid system so that the expected value of some meaningful cost-function is minimized. This can be framed as a stochastic optimization problem. We use the sample average approximation method to solve the resulting stochastic optimization problem. We illustrate the method for the optimal design of a thermal management system of a prototypical aircraft.