I have a script that I run using osascript from a Run Script Build Phase in Xcode 4. This script does some checks to try and catch any human-error in plists and suchlike.
In Xcode 4+, you could run this script as a pre- or post-action script on the "Archive" action. However, pre- and post-action scripts are not considered part of the build itself; their output is not part of the build log, and a failing script will not cause the build to fail.
If you want to include this script as a first-class part of the build, such that its failure will cause the build to fail, then you'll want to do something else. Make a new "External Build System" target, and configure it to run your script. The path to your script can be a relative path, relative to the project root.
Finally, open your main project scheme, and in the "Build" tag add the new checker target, and set it to only be included in the "Archive" action. This should cause your checker script to be run as part of the build only when "Archive" is selected, and if the script returns a non-zero value the build will fail.
If you don't do 3. the script will run all the time, but if you check that box, it will only run when archiving.
A quick test on my own system shows no difference in the detailed script output between straight "Build" and "Build and Archive".
Also, you can't test for the presence (or absence) of the archive, since it only gets created at the very end of the process, when all scripts have been run.
As far as I can see, there is no current option within Xcode 3 to do this. Maybe file an enhancement request with Apple?
While you wait on Apple, the only solution I can offer is to use xcodebuild and xcrun as part of a command-line shell script, where you would know if you are archiving or not. This is not a stay-in-Xcode solution, but it does have a lot of flexibility.
Xcode "Build and Archive" from command line