Giants reliever Jeremy Affeldt, a member of all three world championship teams, will retire at the end of the season.