Cardio: Avoid shallow breaths since they are often an indicator that you are working too hard. Shallow breathing also indicates that you haven't established a suitable breath pattern for your activity. You want to take stronger and deeper breaths when doing cardio, so take the time to find your rhythm.
Strength training: Generally, you want to breathe out on the difficult part of the lift or move to help stabilize your body during exertion. Exhale when you are lifting a hand weight to your shoulder during a bicep curl. This helps you engage your core to prevent you from swaying into your heels, which is cheating and could set you up for a lower-back injury. Think: "Inhale to prepare."
Stretching: Slow, steady breathing is preferable when stretching and will help you relax. Try to focus on breathing from your diaphragm, which will make your belly move out on the inhale and not your chest and shoulders.