Blocking all outgoing connections is a bad idea since that would prevent you from installing software from online repos, doing DNS searches (which would be terrible in most of the environments), keeping the clock updated with NTP, etc.
Anyways, if you still want to do it, try this:
# Drop all connections initiated from this host
iptables -t filter -I OUTPUT 1 -m state --state NEW -j DROP
# Additionally, log the event (optional)
iptables -t filter -I OUTPUT 1 -m state --state NEW -j LOG --log-level warning \
--log-prefix "Attempted to initiate a connection from a local process" \
--log-uid
You can make the rules smarter by allowing certain traffic, like DNS. You can achieve that by two means:
Make the matches more complex. Would be fine for one or two "whitelisting" items. Example:
# Only forbid non-UDP traffic
iptables -t filter -I OUTPUT 1 -m state --state NEW \! -p udp -j DROP
Prepending rules which match some of the desired services which are allowed to be initiated from the local host with a "-j ACCEPT" target. Example:
# Run this after the "DROP" rule to allow connection to ports
#+ 80 and 443, mostly used for HTTP and HTTPS traffic
iptables -t filter -I OUTPUT 1 -p udp -m multiport --ports 80,443 -j ACCEPT