If you know you will be hospitalized for a planned surgery you should contact the parish before you enter the hospital to arrange a time celebrate the sacrament. Often the Sacrament of Anointing can be celebrated after Mass. Call the Parish Office to make an arrangement for the Sacrament.
If someone is in the hospital, simply notify the Hospital Chaplain and they will make arrangements for the Sacrament of the Sick.