Use only internal display I charge my Mac through an external display's using USB-C port. The external display has one another PC computer connected to it too.
When the connected PC goes to sleep, my Mac's screen pops up on the external display.
How can I set things up such that my Mac use the external monitor only for charging and not for display.
This needs to be configured on your external display and not on the connected device (Mac, PC or anything else).
Make sure your external display is set to not switch to a different source automatically.