Wiring which is exposed and that runs through a wall often needs to have an electrical box at the wall or be in a conduit. Home inspectors often point this out and recommend up-grading.
The main reason for this is to have the wiring protected from damage where it passes through the wall. Generally adding an electrical J-box is an easy way of improving this. Usually this can be corrected easily and in a short amount of time.
Who to consult? An electrician or qualified handyman.
Electricians can usually do this type of work easily and quickly.