Four-time Formula One world champion Sebastian Vettel will retire at the end of the 2022 season, he announced on Thursday.