An optimal control problem for a singular system of solid-liquid phase transition