A script (.sqs) file goes in the mission folder beside the mission.sqm file. To make a script work, it must be explicitly called (activated) from inside the mission.
When you export the mission from the mission editor, thereby creating the .pbo, the .sqs file gets wrapped up inside the .pbo.
Scripts that are required by an addon are wrapped inside the addon .pbo.
Read macguba's guide to mission editing for beginners, snYpir's A Friendly Intro to Code Snippets and Johan Gustafsson's Scripting Tutorial. All in the Editors Depot.