By default Xcode 4 will compile and put the final executable in the ~/Library/Developer/Xcode/DerivedData/ directory.
I am happy to use this location for my iOS app, but can I change this setting on per project basis when I write an OSX command line app? (i.e. I do not want to modify XCode-> Preference-> Location because it will be applied globally)
Yes you can.