You incorrectly formulated the original equation in your code in two important ways :
First, note that the equation expresses only relative distortions; that is, in the equation, if x[i]==x[i-1]==x[i+1] then x"[i]=0 no matter how far x[i] from zero. In your code you measure the absolute distance from the equilibrium for each particle, that is, the equation captures a series of oscillators only at the boundary, like a single spring held at the ends, but you simulate a whole set of small springs, each of which is fixed at some "equilibrium" point.
Secondly, your terms are like osc[i].acc+=+k*(osc[i-1].loc-osc[i-1].bloc); don't make much sense. Here you set osc[i].acc , based solely on the position of the absolute particle next to it, and not on the relative position between them.
This second problem is probably why you are gaining energy, but this is only a side effect of incorrect modeling, not necessarily implying that your simulation is causing errors. There is currently no evidence that you need to go from simple Euler modeling (as Nathan suggested). First get the right equation, and then come up with a modeling method if you need to.
Instead, write an equation for relative displacements, i.e. with terms like osc.loc[i]-osc.loc[i-1] .
Comment: I rarely want to comment on the answers of others to the question I answered, but both Nathan and ja72 focus on things that simply are not the main problem. First get the right simulation equations, and then maybe worry about more convenient approaches than Euler, as well as how to update your conditions, etc., if you ever need to. For a simple, linear first-order equation, especially with a slight attenuation, the direct Euler method works great if the time step is small enough, so work it out first.