In OS 9 and back, if you have a monitor that supports multiple resolutions, you can change resolutions with a command in the scripting addition Jon’s Commands. This popular suite of commands includes “set screens”, which will do the job.
Here is a simple example:
set screens to {screen size:{640, 480}}
In OSX, you can use the Lynn Pye’s command-line utility cscreen, which you can download here.
Eg:
do shell script "path/to/cscreen -x 1024 -y 768"