Ternus, Apple’s senior vice president of hardware engineering, will be the new chief executive as Tim Cook becomes executive chairman.