How to specify testnet via curl against json-rpc?
The port 18332 is the specification you speak of. 
When the testnet bitcoind is running on your system, port 18332 is open to accept rpc's. In case of mainnet, that port changes to 8332.

Every thing that you can do from the commandline is accessible via curl on that port.