You should really understand the algorithm that calculates when fees are required and what they are in the Bitcoin source code before attempting to roll your own transactions, otherwise you will likely duplicate blockchain.info wallet fail where they send transactions without adequate fee or non-standard transactions that will never confirm.
https://en.bitcoin.it/wiki/Transaction_feeA safe minimum is 0.0001 BTC per 1000 bytes (rounding up transaction size) for
any transaction, if you want timely processing. If this BTC amount were to be adjusted, you would find it on line 50 of
https://github.com/bitcoin/bitcoin/blob/master/src/main.cppOne caveat is that this calculation must be correct for the
final transaction that is broadcast. Adding a fee can change the payment inputs that are used and the size of the transaction.