It looks like you have some overhead for sum calculation, instead of loading all objects to memory you could just calculate sum on DB level and get results.
scoped_sercvio = Servicio.where(:id => servicio_ids)
self.total_porcentaje_clinica = scoped_sercvio.sum(:porcentaje_clinica)
You can even do nested calculation, such us multiplication on DB level. eg.
self.total_porcentaje_doctor = scoped_sercvio.sum('porcentaje_doctor * price')
Robots wrote article about it, you could check it out here http://robots.thoughtbot.com/refactoring-ruby-iteration-patterns-to-the-database