I think you use the knit button to create the pdf-file. In that case you get normally the same name as the Rmd file. The most simple way to create b.pdf from a.Rmd is to use:
However it is possibile to specify what will happen when you click the knit button by adding the statement knit: (function (...) { your_knit_function(...) })
to your YAML statements.
See for an example the function HOQCutil::my_knit in my HOQCutil package on GitHub. You can install the package to try it or just copy the functions in the R-file and deleting from them everything in it that you don't need.