This can happen to bonded restorations over time. They can absorb some stain over time, but fortunately this stain often is superficial. The first thing a dentist can try is to take some sandpaper or a fine diamond bur and remove the superficial layer of composite. Often, directly under this surface lurks the ‘fresh’, original shade of composite. This 'freshening' of a composite restoration can often extend the esthetic lifetime of a bonded restoration.
A more vexing problem is stain at the margin of a bonded restoration. Although often it is superficial and can be dealt with by light sanding, sometimes the stain can extend deeper into the tooth and can not be addressed by simple sanding of the superficial layer. If the stain is deep but not associated with decay, then a small fine diamond can be used to remove it and a new layer of composite can be applied to 'spackle' the groove that the fine diamond made.
I should be noted that some stained restorations that a dentist suspects have recurrent decay, should be replaced in their entirety and not just sanded or 'spackled'.