Trimming is the process of grooming or shaping a tree or shrub to achieve or maintain a specific design. Pruning is performed for the health of a plant. Typically pruning involves removing diseased or dead portions of a tree or shrub. Pruning can also be used to stimulate blooming in flowering trees and shrubs.
Trimming and Pruning can be performed any time. As for the ideal time, you want to avoid times of drought or extreme heat as plants will be stressed. Another consideration is the times at which particular plants bloom. Trimming and pruning just before a plant is scheduled to bloom will not hurt the plant, but will prevent it from blooming till the following cycle.