Thanks, your reply was just enough info for me to find this page:
https://www.dokuwiki.org/devel:css and after some digging in the monobook template I figured it out.
In case anybody is interested, I achieved the desired result by adding the file 'conf/userall.css' with the following css code:
div#dokuwiki__content h1,
div#dokuwiki__content h2 {
border-bottom: 1px solid #aaa;
margin: 1;
padding-bottom: 0.3em;
padding-top: 0.5em;
}