How to change this simple code so that it sends the email notification after payment in WooCommerce?

The hook you’re looking for is “woocommerce payment complete” and it’s triggered once an order has been marked as “complete”. In the function called by that hook, you need to grab all coupons applied to the order, and check if any of them is the one you’re looking for.

add_action( 'woocommerce_payment_complete', 'so_payment_complete' );
function so_payment_complete( $order_id ){

        // Get an instance of WC_Order object
        $order = wc_get_order( $order_id );

        // Coupons used in the order LOOP (as they can be multiple)
        foreach( $order->get_used_coupons() as $coupon_code ){

            // Retrieving the coupon ID
            $coupon_post_obj = get_page_by_title($coupon_code, OBJECT, 'shop_coupon');
            $coupon_id       = $coupon_post_obj->ID;

            // Get an instance of WC_Coupon object in an array(necessary to use WC_Coupon methods)
            $coupon = new WC_Coupon($coupon_id);
            $coupon_code = $coupon->get_code();

            // Check if it's the right coupon
            if ( $coupon_code == 'mycoupon' ){

                $to = "[email protected]";
                $subject = "Coupon $coupon_code has been applied";
                $content = "
                The coupon code $coupon_code has been applied by a customer
                ";

                wp_mail( $to, $subject, $content );

            }

        }
}