"Is anyone among you sick? [You]should call for the presbyters of the church, and they should pray over [you] and anoint [you] with oil in the name of the Lord, and the prayer of faith will save [you], and the Lord will raise [you] up. If [you have] committed any sins, [you] will be forgiven." James 5:14-15
The Sacrament of Anointing or Healing is commissioned by the Lord and is reflected in the Epistle of James and in many other places in Scripture. Through this Sacrament administered by a priest [presbyter], the Lord increases the divine life in an ill person; sometimes restores health to that person; gives the graces needed to accept the illness; forgives sin and removes the temporal punishment due to sin. Often this anointing is done in conjunction with Eucharist or Confession.
Special oil consecrated by the Bishops [OS] is used by the Priest as the "laying on of hands" is usually performed with prayer. The Priest "signs" using OS the forehead of the person. This anointing is in the form of the Cross. Other parts of the body may be anointed by the priest as well as appropriate.
The Sacrament may be administered in any circumstance pastoral practice permits. Generally, it is at time of health crisis and may be at "time of death" thus the occasionally used term "Last Rites" or "Extreme Unction". Last Rites actually involve more than an anointing including a release of the person into the Hands of God.
Again, as with the other Sacraments, the action and grace given depends upon God and the need of the individual. There is no "formula" for what happens. It is a response to the command of the Lord, Sacred Scripture and Apostolic Tradition.