If you don't plan on using them both at the same time, as the first reply mentioned, a KVM switch will do what you want. You can usually switch "output" computers by using a physical switch on the KVM or a special key combination (like tapping Scroll Lock twice).
As the second poster mentioned, Synergy will work, but you'll need to leave one of the computers (the Synergy "server") on whenever you want to use the other computer (Synergy client). I used this about 8 or 9 years ago and it was pretty neat to use my PC and Mac at the same time with separate displays but the same keyboard and mouse as if they were one computer, but it's not quite the same as a KVM. Of course, Synergy also requires the computers to be able to talk to each other over your network, but that's probably a reasonable assumption these days.
Basically, I'd choose your options depending on what the situation is with your display. The KVM might be better if you only have one display (unless you configure Synergy to make it very hard to accidentally move over to the other computer--otherwise when using the PC, for example, you might accidentally and confusingly move the cursor over to the Mac screen you can't see). In the unlikely even the KVM supports HDMI, you could even get by with putting both computers into the same HDMI port on your monitor, but I don't you'll find that. Most KVMs will still work with just the K and M parts.