I have IBS like symptoms due to losing part of my colon and almost all of my sigmoid (colorectal cancer in 1999). I have struggled with IBS symptoms ever since (the D ones, not C). When I am really messed up and going more than my usual 12-15 bm's a day, in other words all out D or almost D (what I call the messy putty stage), I feel depleted, wrung out, cold, achy and a headache almost always starts. I have had headaches since I was a teenager (52 now). I've had my share of migraines too (long before cancer). But for some reason, and maybe it's because I am dehydrated when I'm messed up, I get a headache too. I just make sure I keep my fluid intake up and take Motrin. Also salty snacks really help - my first choice is almost always pretzels, but a close second are regular Club Crackers with salt (not whole grain or low sodium). Both seem to sooth something in my system. I know we should refrain from caffeine but a regular Pepsi helps too - for the headache and also to restore fluids (but I also down 2 glasses of water right away and only have 1 Pepsi when I'm messed up).
One thing I have learned along the way is I need to keep my fluids up, all the time. Along with a simple, plain diet and 4 to 6 small-small meals a day, 3 large meals like I used to eat just overwhelm my system. Just recently I had a mid afternoon dental appt. coming up and I knew I had to be able to sit in that chair for 2 long hours without a bathroom trip. For lunch, I literally had 2 grapes, 1 cracker, 1 half piece of cheese. Along with a glass of water. I felt full and my GI tract didn't rumble at all - I felt great and could sit in that dental chair without problems. I could have just had 1 or 2 glasses of water but I was hungry. So I thought I would try eating very small amounts of food. And it worked!
But fluids are very important. I've read that there is a connection to headaches/migraines and dehydration. So I don't think you're off track in connecting the two. IBS with D is draining!