In this paper, we propose an optimization framework to design a network of positive linear systems whose structure switches according to a Markov process. The optimization framework herein proposed allows the network designer to optimize the coupling elements of a directed network, as well as the dynamics of the nodes in order to maximize the stabilization rate of the network and/or the disturbance rejection against an exogenous input. The cost of implementing a particular network is modeled using polynomial cost functions, which allow for a wide variety of modeling options. In this context, we show that the cost-optimal network design can be efficiently found using geometric programming in polynomial time. We illustrate our results with a practical problem in network epidemiology, namely, the cost-optimal stabilization of the spread of a disease over a time-varying contact network.