In different papers I see these terms with very close definitions. Are they different things? If yes, how one can differentiate them?
You are correct in that these terms are very close in definition, but terminology is not just about identifying a concept. Terminology is also about identifying the perspective from which you will look at the concept and the community to which you, as the researcher, belong. Here, free-riding and social loafing have very different histories.
Social loafing comes from the social psychology literature and is most closely associated with the methods and typical explanations of that field. Thus, you will typically encounter social loafing around discussions of motivation, diffusion of responsibility, and feeling of effort as dispensable.
Free-riding comes from the economics and game theory literature and is most closely associated with the models and methods of those fields. Thus, you will typically encounter free-riding around discussions of cost-benefit analysis, rational choice, and (the paradox of) cooperation.
The only difference in concept (that I know of) comes from the economics focus on rationality. Social psychologists would classify as social loafing situations where the 'slacking' of an individual hurts not only the group, but their own performance as well (they would have individually -- not just as a group -- gotten a higher payoff if they didn't slack). On the other hand, economists, would not consider this as a case of (rational) free-riding, since they reserve that word for social dilemmas where cooperating costs you more than the marginal increase you get from the benefit to the group, but where everybody free-riding is even worse.
Of course, the terms cross-fertilize, especially in the direction of free-riding entering the discussions of social loafing. In the social psychology literature, you will see free-riding used as an explanation of social loafing in cases where the experimenters believe that the choice to loaf is based on a (rational) cost/benefit analysis instead of some of the other factors I discussed.