You have to connect the parameter to the table somehow, and based on that have the table be evaluated based on the output format. Only declaring a parameter with the output format and then using this parameter to set the output format doesn't do much in this respect (in fact, it only adds an additional step).
What you can do instead is to define a helper function and utilise the asis engine for the relevant code chunks.
First, define two functions for PDF and Word, respectively:
```{r, include = FALSE}
is_word_output = function() {
knitr::opts_knit$get("rmarkdown.pandoc.to") == "docx"
}
is_pdf_output = function() {
knitr::opts_knit$get("rmarkdown.pandoc.to") == "latex"
}
These two functions will produce a TRUE or FALSE depending on the output. This can then be utilised via the eval chunk option.
For the PDF table, put the table-producing code in a chunk like this:
```{asis, eval = is_pdf_output()}
[TABLE CODE]
```
And, for the Word table:
```{asis, eval = is_word_output()}
[TABLE CODE]
```
The code chunks are only evaluated when eval = TRUE, which changes depending on the output format you've chosen.