You cannot set umask per directory, it's a process-level value. If you need to prevent others from reading files in a directory, revoke the corresponding permissions bits.
For example, if you've a directory
/home/user/directory with some files and directories which can get permissions like 777 from a process, set the permission bits of
/home/user/directory to something like 700. That will make it impossible for other users (excluding the superuser root) to descend in
I'm paranoid and set the permissions on
/home/user to 750, so only I can read, write and descend in my home directory. This has as consequence that folders like
/home/user/Public cannot be accessed by others, but I can live with that.
Per update of your question: still, you cannot control that in the filesystem (other than using a different filesystem type like FAT which is strongly discougared), you need to do that in your webapp. If your webapp is coded in PHP, you can change the umask on the fly using the
// other code
You could put this in a configuration file, like the file containing the database connection password (thinking in apps like Wordpress).
Remember that it's a process value, some webservers allow you to set it in their configuration files, otherwise you could modify the startup scripts to set the desired umask. Remember that permissions like
644 are quite dangerous for webapps, if the code is sensitive, everyone can read it.