The idea is that through your skilful conduct you build up a stock of merit - a kind of spiritual capital that is earning interest in your karmic bank account. According to many Buddhist traditions, this merit may be transferred to others, especially the dead, sick, or spiritually destitute.
There are specific ceremonies and rituals by means of which merit is transferred. For instance, in Theravada Buddhism, a donor may give food or clothing to the monastic community and then ‘donate’ the merit gained to a departed relative (to help them in the ‘after-life’). As far as I know, there is no need for the other person to agree to receive merit.
Some Mahayana traditions emphasise merit transfer as a means of overcoming spiritual acquisitiveness and expressing compassionate concern for others. The Bodhisattva, or ideal Buddhist, gives all his or her merit away because they want as many beings as possible to benefit from their spiritual virtue. A form of words that one might use to dedicate merit in this way is: ‘May the merit gained in my acting thus, go to the alleviation of the suffering of all beings.’
However, in other traditions, especially Pure Land Buddhism, we do not transfer merit but are the recipients of Amida Buddha’s merit, which is boundless. According to Pure Land Buddhism, we are destitute of merit and therefore may gratefully accept Amida’s merit, which he has accumulated over innumerable lifetimes. This merit is embodied in his Pure Land, which is an ideal place for spiritual practice where those who call on Amida may be reborn at death. This could also be understood as a way of counteracting spiritual pride.