Allow me to welcome to HP Support Forums! It is a great platform to get help from the community, get suggestions and find what has worked for others!
I see that your Officejet printer is printing in black & white while printing the pages in color while connected using the USB. It seems to be an issue with the driver settings on your PC. Try the steps below:
Go to Control panel – Devices and printers.
Right-click on Officejet 5740 - Network and select Printing preferences.
Go to the layout / paper quality tab and look for the “Print in grayscale” / “Grayscale” or “Black & White” printing option.
Make sure that option is unchecked, save the setting and then try printing again.
That should do the trick, but if the issue persists, then try reinstalling the drivers as suggested below:
Unplug the USB cable from the printer and computer if present.
Go to Control panel – Programs and feature – Select all the HP Officejet printer entries and uninstall them.