Welcome to HP Forums,
This is a great place to get support, find answers and tips to your technical queries.
Make sure you select the right printer as a default and printer.
If the issue persists,
As the printer is working fine with the USB follow the below link to change USB to wireless.
Click on this link: https://support.hp.com/us-en/product/hp-deskjet-ink-advantage-5520-e-all-in-one-printer-series/5158535/model/5158536/document/c03418489
Keep me posted, hope this helps you out!
If the information I've provided was helpful, give us some reinforcement by clicking the Accepted Solution and Kudos buttons, that'll help us and others see that we've got the answers!
Have a great day!
Cheers:)