Tesla must replace Elon Musk as board chairman as part of a settlement with US financial regulators.