Barack Obama's top economic adviser, Larry Summers, will leave his post in November and return to Harvard.