On the optimal control of SIR model with Erlang-distributed infectious period: isolation strategies