-O app makes that role the owner, so it can create objects in the database without further grants. Without -O the owner is the user running createdb, usually postgres. Equivalent to psql -c "CREATE DATABASE appdb OWNER app;"
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.