There are two activities, one at the beginning and one at the end.
Whenever we engage in any Dharma activity, there are two important things. First set a pure motivation at the beginning and then conclude with an appropriate dedication. In between the motivation and dedication, we rely upon mindfulness and alertness.
Why are motivation and dedication important? The quality of our karma is overwhelmingly (though not exclusively) determined by our internal intention, or motivation for the action. The same action, such as giving flowers to our wife, can have dramatically different karmic results. If we give her flowers for selfish reasons, such as we want her to forgive us for forgetting our anniversary, then the karmic result will at most be some mild forgiveness. If we give her flowers because we want others to give us flowers in our future lives, that is what will happen. If we give her flowers motivated by renunciation wishing to escape from samsara, then the action will ripen in a pure karmic seed which will contribute to our liberation. If we give her flowers imagining that by doing so we are giving flowers to countless living beings, we multiply the good karma by the number of beings we imagined we are giving them to (namely countless). If we give her flowers with a bodhichitta motivation, the action will ripen in the form of our enlightenment. Same action, different motivations, different karmic results. The same is true for any virtuous action. So by setting a good motivation at the beginning, we can make sure we get the maximum karmic benefit from our spiritual efforts.
Dedication is important because the mental action of dedication completes the virtuous karma we just accumulated, determining how it will ripen. We can dedicate our virtues to winning the lottery or for the enlightenment of all beings, but the karmic results will be vastly different. Dedication is like choosing how to invest our money. If we earn a lot of money and want to invest it, we need to decide what to invest it in. In exactly the same way, when we accumulate a lot of merit from our Dharma practice, we need to choose what to invest it in. The greater the “scope” of the karmic investment fund we place it in, the higher the spiritual return. Just as there are four different scopes of being, so too there are four different scopes of dedication. An ordinary, initial scope being is concerned with the welfare of this life alone, and their dedication is made towards that end. This has the lowest spiritual return on it. A special, initial scope being is concerned with the welfare of all their future lives, and their dedication is made towards that end. The same is true for an intermediate scope being striving for liberation and a great scope being striving for enlightenment. The spiritual return of an initial scope being can be liked to a spark, the return of an intermediate scope being can be likened to a candle, and the return of a great scope being can be liked to the blazing of the sun. It is important to note that the scope of our dedication (and our motivation for that matter) are not determined by the words we say, but rather by the mind with which we say them. Just as it is possible to hold Mahayana tenets with a Hinayana motivation, so too it is possible to recite a Mahayana dedication verse with a worldly motivation with only worldly results.
Dedication also functions to protect the merit we have accumulated from our subsequent anger and other delusions. All delusions, but anger in particular, function to destroy the non-dedicated virtuous karma we have previously accumulated. The reason for this is easy enough to understand. If a wave with an amplitude of +1 is hit with a wave with an amplitude of -1, the result will be the cancellation of any wave at all. In the same way, when the positive wave of our virtues is hit with the negative wave of our delusions, the result will be the neutralization of our virtuous karma. It will be as if we never engaged in the virtuous action at all. Anger in particular is destructive because it runs exactly counter to all virtue. The wish of anger is to harm, which is exactly the opposite of all virtuous wishes. Since our virtues are still weak whereas our anger is strong, anger burns through our merit like a wild fire after a drought. In particular, anger directed at a bodhisattva is karmically equivalent to wishing to harm all living beings (wishing to harm somebody who wishes to help all living beings indirectly harms all living beings). Such anger almost instantly can wipe out aeons worth of non-dedicated merit.
When we dedicate our merit, however, the merit develops a type of special protective sheathing. If we saved our money by putting it under our bed, it can be destroyed in a fire; if we saved it by putting it into the bank, it is safe. If our wealth is primarily our house and we have no insurance, if it burns down, we lose everything. But if we do have insurance, our wealth is safe even if the house burns down. It is the same with dedication.
Very often we quickly blitz through generating a motivation because we want to get to the meat of the main practice. We likewise distractedly recite our dedication prayers because we know as soon as we finish our practice we need to start our day. During the day itself, we rarely if ever take the time to establish a good motivation and the beginning and almost never take the time to dedicate at the end. As a result, all of this virtue largely becomes wasted. We would not leave the family jewels just lying around, but would take great pains to make sure they were safe. In the same way, we should not leave the inner jewels of our virtuous karma unprotected by not dedicating them. We need to apply effort to make setting our motivation and dedicating to be our new habit, but of all the habits to cultivate, this is the most important one.