They can't. That's the whole point.
In the original film, hosts had hands that weren't quite right, so you could pick the hosts out by looking closely at their hands but in the TV show there is no visible way to tell whether a being is human or machine.
As the hosts are not self aware, even their programming doesn't allow them to differentiate because they have no clue that they are different - they believe themselves to be human. Hosts would be universally unfamiliar with the guests (provided it is their first visit) while they would know many of the other hosts because they recognize them as members of the community. More on this in a bit.
If you really want to know whether a person is guest or host, the simplest option would be to show them something anachronistic to their world but commonplace in the real world and ask what it is. The hosts will be unable to recognize the object (if they are even able to see it at all), though this won't necessarily catch someone pretending to be a host. A more violent option that would always work would be to shoot them. If they don't get hurt, they are human. If they get shot, they are a host.
While the hosts aren't actively aware that there is a difference between Guests and Hosts, they do have programming that causes them to act to save a guest if they feel that guest is in danger. This is called the "Good Samaritan Reflex". From an Entertainment Weekly interview with the showrunner, Lisa Joy:
William is told he can’t get hurt in Westworld. But what about being hurt by another guests? What’s to keep a guest from stabbing him thinking he’s a robot? Is there a safe word?
Joy: We talked a lot about the rules of the park. A lot of it isn’t made explicit in the series but there’s something called the Good Samaritan Reflex within the hosts. So say you’re in a bar fight and some guy has a knife and maybe there’s even another guest that you didn’t know and he thinks you’re a host and he’s gonna stab you in the back. In that instance, a good Samaritan host would seamlessly intersect and get in that fight and literally take that knife for you. Now accidents can happen – falling off a cliff and things like that. But you know it’s mitigated somewhat because even the animals – aside from the flies – are hosts, so no horse is going to buck you to your death.
This does a good job of addressing public actions. While one would generally assume something like rape would be more likely to be done in private, it's possible that some of the smaller hosts might be used as passive observers that could notify the command center if any between-guest action was taking place, allowing them to send in a host to stop the action or, in extreme situations, a team of human employees to stop it. This would give the guests the feeling of freedom without worrying that their actions are being actively observed. This is further explored in this related question's answer.