The restrictions placed on the use of the ship's radio room could be for any of a number of reasons, the particular restrictions applied in any port depended on the national policy of the port state.
The most obvious but rarely stated one was that of national security. In most totalitarian states, for the citizens of that state the landline and radio communications facilities were strictly controlled and calls and messages were monitored and screened by the security services. It was not acceptable to allow an uncontrolled radio station to operate aboard a ship in their national waters. For that reason the radio rooms were usually sealed for the duration of your stay in such a port.
Another reason was one of commercial nature. Each state used to have a state monopoly on communications; in the case of commercial business communications this would be assigned to one or more operating organisations. In the UK the service was a monopoly, operated by the General Post Office. The service operators did not want ships to be able to avoid paying them for any telephone calls and telegrams sent whilst in port. They wanted you to use the shore facilities to communicate back to your owners or agents outside the country in which you were docked. For that reason you were required not to use the radio station in port. This could be enforced by monitoring the use of the ship's transmitters. However British and Commonwealth ships were usually able to evade those restrictions in the case of telegrams to ships from the UK/Commonwealth.
At published times and on published frequencies, all Coast radio stations would broadcast the callsigns of ships for which they held messages (in the jargon, 'Traffic'). These broadcasts were referred to as 'traffic lists'. One of the duties of the R/O was to monitor the traffic lists of the coast stations from which it might normally be expected to receive messages. When he heard his ship's callsign in a traffic list, the R/O had to fire up his transmitter and call the coast station to ask him to pass on the messages. If use of the radio station was prohibited by local or nationl regulations, the R/O had to wait until he left port to make this contact and get his traffic.
The Area Scheme coast stations not only broadcast the 'traffic lists' but also transmitted the actual messages to the ships 'blind'. This entailed sending out all the messages in sequence, in the same order as listed in the traffic list. That is, they broadcast them without first being contacted by the ship. The R/O copied down all messages for his ship and delivered them. After leaving port he contacted the coast station and acknowledged their receipt. Messages from the ship whilst in port still had to be sent via whatever organisation ran the local telecoms service.
Another reason given was that the use of ships' tranmitters in port and close inshore could cause harmful interference to the communications of the port state. If you were at sea you be familiar with the effects on the Merchant Navy programme, or the snowy picture of the TV, when 'Sparks' started tapping away on the key. The claim was that the people ashore could suffer the same problem if every ship was allowed to use the radio station.
Finally there was the safety claim. Sparks from transmitting radio equipment and antennas aboard the ship might ignite flammable gases from the cargo or other sources in port.
All of the above were considered excellent reasons why the radio room should not be used in port. Whether they were genuine or not, they certainly served me well as a damned good excuse to get off the ship and enjoy myself.
Ron