In the paper the problem of personnel allocation under threat was presented. The possibilities of undertaking optimization measures in the process of workers’ health and safety and expenses incurred were emphasized. A mathematical model for this issue has been formulated. An algorithm solving the problem of staff allocation was presented. The evaluation criterion for this assignment was the minimization of worker safety risks. Simultaneous optimization of expenses incurred in the implementation of production tasks was taken into account. The productivity of the staff and all existing jobs with the skills of the employees also was considered. This problem was solved using GNU Octave. The example presented in the paper shows that in case of the most unfavorable allocation of tasks to employees, it will lead to a significant reduction in profits and may increase the risk of undesirable situations. The proposed analysis is the starting point for determining the risk in case of multi-position work.