It does not violate the law of conservation of energy. The oscillation stops when the energy is lost and the energy is lost because it becomes heat that is created by the air resistance and many other forces found in the surrounding of the oscillating spring.
If a system allows the exchange of energy but does not permit exchange of matter between the system and surroundings, this system is classified as a CLOSED system. The energy that flows in and out of the system boundaries is in the form of heat.