Shops within hospitals will not be permitted to sell the stimulating drinks to anyone under the age of 16.
The ban applies to drinks with an added caffeine content of more than 150mg per litre in an effort to promote a healthy diet.
But doctors are calling for the ban to be extended to all under-16s, not just in NHS buildings.
All NHS catering sites will also adopt the policy.
The move is part of the latest update to the Healthcare Retail Standard, a set of rules all retailers operating in NHS sites in Scotland must adhere to.
It aims to increase the amount of healthier food and drinks in shops in NHS buildings, with tighter rules around what can be promoted.
Most major supermarkets stopped selling the drinks to under-16s in March 2018, while a teaching union has warned they are having a detrimental effect on both the health and the attention span of pupils.
New restrictions on baby food are also being introduced to promote healthy eating as early as possible.
Products will have to contain no added sugar or salt and be unsweetened.
Public Health Minister Joe Fitzpatrick said: "The Healthcare Retail Standard supports healthier eating across the NHS estate and it is right that our hospitals show a lead in providing food and drink which is health promoting.
"The HRS ensures that at least 50% of food and 70% of drinks on sale are healthier options.
"This supports the Scottish government's strategy of working to improve Scotland's diet and tackle health inequalities."