This is variable depending on how you operate your heat pump and what it is being used for. For example, if you turn it off and on regularly or have it running on max flow temperature this will likely reduce it’s lifecycle.
The average ground source heat pump has a lifecycle of 20+ years but of course there are outliers depending on a number of factors as mentioned prior.
For a ground source system, the geothermal ground loops can last considerably longer than the heat pump itself. Usually, these collectors can last between 50 and 100 years.
The average Air Source Heat Pump “can operate up to 20 years” but due to exposure to the elements they typically need routine maintenance and likely more replacement parts.