The NIH Genetics Home Reference Handbook explains that mutations are passed to offspring if these mutations are present in germ line (sperm or egg) cells. Germ line mutations can occur early in the parent's development so that they affect all of the cells in the parent's body, including eventual gametes. These mutations can also occur in gametes alone and therefore only affect offspring.
Nature magazine explains that there are different types of mutations. There is a chance of mutations occurring every time a cell divides, as DNA polymerases (the proteins that replicate DNA) are not perfect. Mutations that occur during mitosis of non-germ line cells are called "somatic mutations" and will not be passed to offspring.
Another limitation on whether or not mutations are passed onto offspring involves the effects of the mutation. As explained by Nature and Wikipedia, some changes to the DNA sequence are deleterious to the organism. In some cases, the effect of the mutation is so severe that it can not be passed to offspring because it results in embryonic lethality.
Curiosity at Discovery.com states that although some mutations that are passed to offspring can increase the risk of cancer, these only increase cancer predisposition. As an example, mutations to the BRCA1 gene increases the risk of breast cancer, but these mutations are not sufficient to ensure cancer.