How long a filling lasts depends very much on its size.
Composite is a plastic which is prone to wear in the mouth. If a filling is extensive (covers a large surface area that is in contact during biting) then it will tend to wear out more quickly than a small one. Wear or failure (breakage etc) of the filling is more likely if you grind your teeth.
On average, a small composite should last at least 5 years.
Larger composites can tend to break down quickly, leading to loss of the filling, or more insidious changes to your bite over time which can be difficult to recover. For larger cavities, crowning the tooth or placing a ceramic/metal (such as gold) filling may be more long lasting.