Tim Cook will hand over the role to John Ternus, the company's head of hardware engineering, on September 1, while staying on as executive chairman.