The most effective way to minimize the risk of free riders is to create a corporate culture in which members of the organization trust one another and care about doing their job correctly. This reduces the desire to free ride when part of a team.
However, this is more easily said than done. There are other things that can be done that are simpler and may get the job done. For example, you can make sure that people work together in a variety of circumstances. This can inhibit free riding because the person who is inclined to slack off (Person A) might think twice because they will know that they will have to work with these coworkers in teams again. Person A might fear, for example, that others will slack off in a situation in which Person A will end up in trouble if things are not done right. Thus, Person A will work hard in hopes that others will reciprocate when he/she is in charge.