Flexibility is vitally important in martial arts. It not only make your body able to perform the movement of your art, it also helps your body become easily adaptable to the change needed in learning new skills!
Static stretching is the most common way to increase flexibility. Static stretching is done in a fixed position without a lot of movement. There is also Dynamic stretching, usually in the form of leg raises or arm swings.
According to this article: 10 Static Stretching Basic Rules, static stretching should be done after an extensive workout. Sure, do some stretching before a workout to warn the muscles that activity is about to happen, but for proper hard static stretching you want to be really war.
Be sure to stretch both agonist and antagonist muscle groups. This is to create a balance and prevent injury. More importantly, always observe proper posture in static stretching. Never slouch and never attempt bouncing while doing so. This will cause tearing of the muscle fibers. In order to avoid pain and injury, you need to change your execution if it results in excessive pain. Never attempt an abrupt stretching. Gradual progress is advisable.