Is this a problem with my code
No, because your code isn't generating the IP checksum. That's either generated by the OS's networking stack or, as Nikolai Fetissov noted in his answer, by the network adapter.
If your network analyzer is running on the machine that sent the packet, and the checksum is generated by the network adapter rather than by the networking stack, then, because capturing your own packets is done by the networking stack "looping those packets back" to the capture mechanism rather than by the network adapter capturing the packets that it transmits (which few if any adapters will), the captured packets will not have had the IP checksum calculated and will thus almost certainly appear to have a bad IP checksum.
Note the "may be caused by "IP checksum offload"?" in the Wireshark display. That's what Wireshark is talking about.