This can be done in workflows (available in Professional and Enterprise subscriptions). You would create a contact-based workflow, enrolling contacts when Last activity date is more than 26 weeks ago, for example. This would then be followed by a Set a property value action, setting the contact owner field to your desired owner.
Without workflows, I'd approach this with Zapier., probably adding contacts without activity in a contact list, sending new contacts from that list to Google Sheets with Zapier, updating the owner column and sending it back to HubSpot. If you follow this approach, make sure your data privacy officer signs of on processing contact data in two more systems (Zapier, Google Sheets).
Hope this helps!
Karsten Köhler HubSpot Freelancer | RevOps & CRM Consultant | Community Hall of Famer