Optimal control of semi-Markov processes with a backward stochastic differential equations approach