Stochastic optimal control of delay equations arising in advertising models