Homogenization of second order energies on periodic thin structures