The first question to ask is whether you want to protect yourself at all.
Epidemics in medieval Europe were generally considered a sign of God's wrath, if not of the full-blown end-of-the-world apocalypse. As texts by grumpy medical practitioners make apparent, there were plenty of people advising not to fight the plague, especially with medical treatment; that God needed to pour out his anger on humanity.
The more common religious response--and the most common response in general--was the attempt to appease God's wrath. Individual prayer and fasting, attendance at Mass, and organized penitential processions through the streets (sometimes consisting solely of Church personnel) were rituals that preachers frequently urged in their sermons from church porches.
Some people certainly had other ideas. The most famous is depicted in Boccaccio's Decameron, in which a group of--here, wealthy--Italian urbanites flees to the countryside and passes the time telling stories. And not necessarily, shall we say, religious stories.
But those physicians and surgeons insisting on the viability and acceptability of medical treatment were often as interested in helping people not get sick in the first place, as they were with healing them. Nuremberg barber (barbers were legally required to stay in cities and treat pestilence victims, which physicians were not) Hans Folz drew on some remedies from famed Muslim scholar Avicenna, as well as Greek medical writer Galen, to offer his readers some ideas. I don't have his Reimpaarspruche (the primary source collection) with me right now, but I do know: like many remedies of this time period, it involved mixing various spices in with rose water.
The actual ingredients were probably not affordable to the average domestic servant or urban day laborer, but somebody or other was probably selling knock-offs at a drastically "reduced" price.
So those are some things that you could do to prevent yourself from getting sick. Whether they would work or not...that's a different question.